哪位老铁谁能给我解一下这个java题,,谢谢啦!

哪位老铁谁能给我解一下这个java题,,谢谢啦!工资计算系统: 某公司给员工每周结算工资。有 4 类员工: 固定工资员工(salaried employee):无论多少工作时间,工资固定 小时员工(hourly employee):按工作的小时数支付工资,每周工作时间超过 40 小时外的部分按正常的 1.5 倍计算 业绩提成员工(commission employee):依据本周销售业绩以一定的比例提成作 为本周工资 基本工资附带提成员工(base-salaried commission employee):基本工资外加 本周业绩提成 综合应用所学知识,采用 Java 语言实现上面工资计算系统中的 4 类员工的工资计算

第1个回答  2017-05-22
//看看这样行吗?以前做过这道题
public class EmployeeTest {
public static void main(String[] args) {
Employee e1 = new SalariedEmployee(200);
System.out.println("工资为:"+e1.salary());
Employee e2 = new HourlyEmployee(50, 100);
System.out.println("工资为:"+e2.salary());
Employee e3 = new CommissionEmployee(1000, 0.5);
System.out.println("工资为:"+e3.salary());
Employee e4 = new BCommissionEmployee(200, 2000,0.3);
System.out.println("工资为:"+e4.salary());

}

}
class Employee {
public double salary(){
return 0;
}
}
class SalariedEmployee extends Employee{
double s;//基本工资
public SalariedEmployee(double s){
this.s = s;
}
public double salary(){
return s;
}
}
class HourlyEmployee extends Employee{
double time;
double s;
public HourlyEmployee(double s,double time){
this.s = s;
this.time = time;
}
public double salary(){
if(time < 40)
return s*time;
return (time - 40)*1.5*s+40*s;
}
}
class CommissionEmployee extends Employee{
double results;
double rate;
public CommissionEmployee(double results,double rate){
this.results = results;
this.rate = rate;
}
public double salary(){
return results*rate;
}
}
class BCommissionEmployee extends Employee{
double s;
double results;
double rate;
public BCommissionEmployee(double s,double results,double rate){
this.s = s;
this.results = results;
this.rate = rate;
}
public double salary(){
return results*rate+s;
}
}追问

好滴谢谢

我看哈

本回答被提问者和网友采纳
相似回答