public class EmployeeSalary extends Employee{//子类,继承了Employee
String empname;//员工名称
String empkind;//员工种类
double tsalary;//基础工资
double flsalary=0.0;//员工当前应得工资
int classyr=0;//工作年份
public EmployeeSalary(String name,String empkind,double tsalary,int classyr){
super(tsalary);
this.empname=name;
this.empkind=empkind;
this.classyr=classyr;
this.tsalary=tsalary;
}
public void getEmployeeSalary(){
switch(empkind){
case"一线员工"://一线员工加成18%
flsalary=super.getSalary(classyr)*(1+0.18);
break;
case "非一线员工"://非一线员工加成18%
flsalary=super.getSalary(classyr)*(1+0.18);
break;
}
System.out.println(empname+"基础工资"+tsalary+"工作了"+classyr+"年。"+"属于"+empkind+"。综合工资是"+"flsalary");
}
public static void main(String[] args){//利用主方法进行测试
new EmployeeSalary("张三","一线员工",1100,1).getEmployeeSalary();
new EmployeeSalary("张八","非一线员工",1100,6).getEmployeeSalary();
}
}
网友评论