package co.hp.zy;
public class Employee {
private String name;
private int month;
public void self(){
}
//getSalary(int month) 根据参数月份来确定工资,如果该月员工过生日,则公司会额外奖励100元。
public void getSalary(double jcgz){
if (this.month == 7){
System.out.println(this.getName()+"过生日,公司额外奖励100元月薪,为:"+(jcgz+100));
}
}
public Employee() {
}
public Employee(String name, int month) {
this.name = name;
this.month = month;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getMonth() {
return month;
}
public void setMonth(int month) {
this.month = month;
}
}
package co.hp.zy;
public class SalariedEmployee extends Employee {
//Employee的子类,拿固定工资的员工。
private double monthlyPay;
public double getMonthlyPay() {
return monthlyPay;
}
public void setMonthlyPay(double monthlyPay) {
this.monthlyPay = monthlyPay;
}
public void monthlyPay(Employee employee){
this.setMonthlyPay(8000);
System.out.println(employee.getName()+"拿的是固定月薪,为:"+this.monthlyPay);
//如果过生日了
employee.getSalary(this.monthlyPay);
}
}
package co.hp.zy;
public class BasePlusSalesEmployee extends SalesEmployee {
// SalesEmployee的子类,有固定底薪的销售人员,工资由底薪加上销售提成部分。
private double dx;
public BasePlusSalesEmployee() {
}
public BasePlusSalesEmployee(double dx) {
this.dx = dx;
}
public double getDx() {
return dx;
}
public void setDx(double dx) {
this.dx = dx;
}
//销售的固定底薪
public void xsdx(Employee e,double dx){
System.out.println("销售的固定底薪为"+dx);
SalesEmployee s = new SalesEmployee();
//调用销量和提成率
double aa = s.yxMoney(30000,0.1);
//最终工资
double jcgz = dx+aa;
System.out.println(e.getName()+"的总工资为"+jcgz);
//调用过生日
e.getSalary(jcgz);
}
}
package co.hp.zy;
public class SalesEmployee extends Employee{
// Employee的子类,销售人员,工资由月销售额和提成率决定。
private double yxMoney;
private double tcl;
public double yxMoney(double yxMoney, double tcl){
System.out.println("月销量为"+yxMoney+"提成率为"+tcl);
double ultimately = yxMoney*tcl;
return ultimately;
}
public double getYxMoney() {
return yxMoney;
}
public void setYxMoney(double yxMoney) {
this.yxMoney = yxMoney;
}
public double getTcl() {
return tcl;
}
public void setTcl(double tcl) {
this.tcl = tcl;
}
}
package co.hp.zy;
public class Empl {
public static void main(String[] args) {
Employee[] employees = new Employee[3];
employees[0] = new Employee("小红",7);
employees[1] = new Employee("小蓝",9);
employees[2] = new Employee("小率",4);
SalariedEmployee salariedEmployee = new SalariedEmployee();
BasePlusSalesEmployee b = new BasePlusSalesEmployee();
HourlyEmployee h = new HourlyEmployee();
//salariedEmployee.setMonthlyPay(8000);
salariedEmployee.monthlyPay(employees[0]);
System.out.println("--------------------------------");
b.xsdx(employees[1],5000);
System.out.println("--------------------------------");
h.huors(employees[2],26,370);
}
}