package mmm;
public class ColaEmployee {
String name;
int month;
public ColaEmployee() {
}
public ColaEmployee(String name, int month) {
super();
this.name = name;
this.month = month;
}
public double getSalary(int month) {
return 0;
}
}
package mmm;
public class SalariedEmployee extends ColaEmployee {
double n;
public SalariedEmployee(String name, int month, double n) {
super(name, month);
this.n = n;
}
public double getSalary(int month) {
if (super.month == month) {
return n + 100;
} else {
return n;
}
}
}
package mmm;
public class HourlyEmployee extends ColaEmployee {
private int a;
private int b;
public HourlyEmployee(String name1, int month, int a1, int b1) {
super();
this.name=name1;
this.b = b1;
this.a = a1;
}
public double getSalary(int month) {
if (super.month == month) {
if (b > 160) {
return a * 160 + a * (b - 160) * 1.5 + 100;
} else {
return a + b + 100;
}
} else {
if (b > 160) {
return a * 160 + a * (a - 160) * 1.5;
} else {
return a * b;
}
}
}
}
package mmm;
public class SalesEmployee extends ColaEmployee {
private int yx;
private double m;
public SalesEmployee(String name, int month, int yx, double m) {
super(name, month);
this.yx = yx;
this.m = m;
}
public double getSalary(int month) {
if (super.month == month) {
return yx * m + 100;
} else {
return yx * m;
}
}
}
package mmm;
public class Company {
public void getSalary(ColaEmployee c, int month) {
System.out.println(c.name + " 在" + month + "月的月工资数额为 " + c.getSalary(month) + "元");
}
}
package mmm;
public class TextCompany {
public static void main(String[] args) {
ColaEmployee[] m = { new SalariedEmployee("固定员工", 4, 100), new HourlyEmployee("小时工",8,300,100),
new SalesEmployee("销售额和提成的", 4, 2000, 0.3) };
for (int i = 0; i < m.length; i++) {
new Company().getSalary(m[i], 10);
}
}
}
