class Main {
public static void main(String[] args) {
Employee [] aaa= new Employee[5];
aaa[0] = new SalariedEmployee("张兴",5,123123);
aaa[1] = new HourlyEmployee("王伟",7,100,50);
aaa[2] = new SalesEmployee("王星",2,98786,0.6);
aaa[3] = new BasePlusSalesEmployee("夏瑜",7,45890,0.7,3432);
}
}
class Employee {
private String name;
private int birthday;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getBirthday() {
return birthday;
}
public void setBirthday(int birthday) {
this.birthday = birthday;
}
int getSalary(int month) {
if(month == birthday) {
return 100;
}else {
return 0;
}
}
Employee() {
}
Employee(String name,int birthday) {
this.name = name;
this.birthday = birthday;
}
}
class SalariedEmployee extends Employee {
private int Salaried;
SalariedEmployee(String name, int birthday, int Salaried) {
super(name,birthday);
this.Salaried = Salaried;
System.out.println("名字:" + name + "\t"+"工资:"+ this.getSalary(birthday));
}
int getSalary(int month) {
if(month == getBirthday()) {
return this.Salaried + super.getSalary(getBirthday());
}else {
return this.Salaried;
}
}
}
class HourlyEmployee extends Employee {
private int nums;
private int Salaried_hour;
HourlyEmployee(String name,int birthday, int nums, int Salaried_hour) {
super(name,birthday);
this.nums = nums;
this.Salaried_hour = Salaried_hour;
System.out.println("名字:" + name + "\t"+"工资:"+ this.getSalary(birthday));
}
int getSalary(int month) {
if(month == getBirthday()) {
return this.nums * this.Salaried_hour + super.getSalary(getBirthday());
}else {
return this.nums * this.Salaried_hour ;
}
}
}
class SalesEmployee extends Employee {
private int money_moon;
private double rate;
public int getMoney_moon() {
return money_moon;
}
public double getRate() {
return rate;
}
SalesEmployee(String name, int birthday, int money_moon, double rate) {
super(name,birthday);
this.money_moon = money_moon;
this.rate = rate;
System.out.println("名字:" + name + "\t"+"工资:"+ this.getSalary(birthday));
}
SalesEmployee(String name, int birthday, int money_moon, double rate,int low_money) {
super(name,birthday);
this.money_moon = money_moon;
this.rate = rate;
}
int getSalary(int month) {
if(month == getBirthday()) {
return (int)((double)(this.money_moon) * this.rate) + super.getSalary(getBirthday());
}else {
return (int)((double)(this.money_moon) * this.rate) ;
}
}
}
class BasePlusSalesEmployee extends SalesEmployee {
private int low_money;
BasePlusSalesEmployee(String name,int birthday,int money_moon, double rate, int low_money ) {
super(name,birthday,money_moon,rate,low_money);
this.low_money = low_money;
System.out.println("名字:" + name + "\t"+"工资:"+ this.getSalary(birthday));
}
int getSalary(int month) {
if(month == getBirthday()) {
if((int)((double)(this.getMoney_moon()) * this.getRate()) > this.low_money)
return (int)((double)(this.getMoney_moon()) * this.getRate()) + super.getSalary(getBirthday());
else {
return this.low_money;
}
}else {
if((int)((double)(this.getMoney_moon()) * this.getRate()) > this.low_money)
return (int)((double)(this.getMoney_moon()) * this.getRate());
else {
return this.low_money;
}
}
}
}