匿名用户
1级
2010-04-13 回答
private Double price; //收费标准
private Integer class_time; //课时
private Integer level; //教师级别 1.助教,2.讲师,3.副教授,教授
private Integer service_time; //教龄
private String name; //职称名
//-------------------Method-----------------
public void setClass_time(Integer classTime) {
class_time = classTime;
}
public Double getPrice() {
return price;
}
public Integer getLevel() {
return level;
}
public Integer getService_time() {
return service_time;
}
public void setService_time(Integer serviceTime) {
service_time = serviceTime;
}
public void setLevel(Integer level) {
this.level = level;
if(level.equals(1) && service_time <= 1){price = 30.00;name="助教";}
else if(level.equals(1) && (service_time > 1 && service_time < 3)){price = 40.00;name="助教";}
else if(level.equals(1) && service_time > 3){price = 50.00;name="助教";}
else if(level.equals(2) && service_time <= 1){price = 40.00;name="讲师";}
else if(level.equals(2) && (service_time > 1 && service_time < 3)){price = 60.00;name="讲师";}
else if(level.equals(2) && service_time > 3){price = 80.00;name="讲师";}
else if(level.equals(3) && service_time <= 1){price = 60.00;name="教授";}
else if(level.equals(3) && (service_time > 1 && service_time < 3)){price = 80.00;name="教授";}
else if(level.equals(3) && service_time > 3){price = 120.00;name="教授";}
}
public Calculate(){}
public Calculate(Integer class_time,Integer level,Integer service_time)
{
this.class_time = class_time;
this.level = level;
this.service_time = service_time;
}
public void Charging()
{
Double result = 0.0;
try
{
result = price * class_time;
}
catch (NumberFormatException nfe)
{
nfe.printStackTrace();
System.out.println("计算出错:\t"+nfe);
}
catch (Exception ex)
{
ex.printStackTrace();
System.out.println(ex);
}
String str = "该"+name+"工龄"+service_time+"年,每课时"+price+"元,总共授课课时为"+class_time+"小时,总计"+result+"元";
System.out.println(str);
}
//--------------------测试方法----------------------
public static void main(String[] args) throws Exception {
Calculate cl = new Calculate();
cl.setService_time(2);
cl.setClass_time(20);
cl.setLevel(3);
cl.Charging();
}