某公司的雇员分为以下若干类:
Employee:这是所有员工总的父类,属性:员工的姓名和生日月份。
方法:getSalary(int month) 根据参数月份来确定工资,如果该月员工过生日,
则公司会额外奖励 100 元。
SalariedEmployee:Employee 的子类,拿固定工资的员工。属性:月薪
HourlyEmployee:Employee 的子类,按小时拿工资的员工,每月工作超出 160
小时的部分按照 1.5 倍工资发放
属性:每小时的工资、每月工作的小时数
SalesEmployee:Employee 的子类,销售人员,工资由月销售额和提成率决定
属性:月销售额、提成率
BasePlusSalesEmployee:SalesEmployee 的子类,有固定底薪的销售人员,
工资由底薪加上销售提成部分 属性:底薪。
class Employee{
private String name;
private int birthmonth;
public Employee(){
}
public Employee(String name,int birthmonth){
this.setName(name);
this.setBirthmonth(birthmonth);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getBirthmonth() {
return birthmonth;
}
public void setBirthmonth(int birthmonth) {
this.birthmonth = birthmonth;
}
public int getSalary(int month) {
if(month==this.getBirthmonth()){
评论0