初学者,不会这题,会的帮帮忙。。。
abstract class Employee{public abstract double earnings( );
}
class YearWorker extends Employee{
【代码1】 // 重写earnings( )方法,领取总工资50000.456元
}
class MonthWorker extends Employee{
【代码2】 // 重写earnings( )方法,每月领取工资2000元
}
class WeekWorker extends Employee{
【代码3】 // 重写earnings( )方法,工作52周,每周工资500元
}
class Company{
Employee[] employee;
double salaries=0;
Company(Employee[] employee){
this.employee=employee;
}
public double salariesPay( ){
salaries=0;
【代码4】 // 计算salaries
return salaries;
}
}
public class HardWork{
public static void main(String args[]){
Employee[] employee=new Employee[20];
for(int i=0;i<employee.length;i++){
if(i%3==0)
employee[i]=new WeekWorker( );
else if(i%3==1)
employee[i]=new MonthWorker( );
else if(i%3==2)
employee[i]=new YearWorker( );
}
Company company=new Company(employee);
System.out.println("工资总额:"+company.salariesPay( ));
}
}