**************************************************************
public abstract class Employee{
private String firstName;
private String lastName;
private String socialSecurityNumber;
public Employee(String first,String last,String ssn){
firstName=first;
lastName=last;
socialSecurityNumber=ssn;
}
public void setFirstName(String first){firstName=first;}
public String getFirstName(){return firstName;}
public void setLastName(String last){lastName=last;}
public String getLastName(){return lastName;}
public void setSocialSecurityNumber(String number){socialSecurityNumber=number;}
public String getSocialSecurityNumber(){return socialSecurityNumber;}
public String toString(){
return getFirstName()+" "+getLastName()+"\n社会保险号:"+getSocialSecurityNumber();
}
public abstract double earnings();
}
*************************************************************
public class BasePlusCommissionEmployee extends CommissionEmployee{
private double baseSalary;
public BasePlusCommissionEmployee(String first,String last,String socialSecurityNumber,double grossSalesAmount,double rate,double baseSalaryAmount){
super(first,last,socialSecurityNumber,grossSalesAmount,rate);
setBaseSalary(baseSalaryAmount);
}
public void setBaseSalary(double salary){
baseSalary=salary<0.0?0.0:salary;
}
public double getBaseSalary(){
return baseSalary;
}
public double earnings(){
return getBaseSalary()+super.earnings();
}
public String toString(){
return "\n拿薪金的代理人:"+super.getFirstName()+" "+super.getLastName()+"\n社会保险号:"+super.getSocialSecurityNumber();
}
}
*************************************************************
public class CommissionEmployee extends Employee{
private double grossSales;
private double commissionRate;
public CommissionEmployee(String first,String last,String socialSecurityNumber,double grossWeeklySales,double percent){
super(first,last,socialSecurityNumber);
setGrossSales(grossWeeklySales);
setCommissionRate(percent);
}
public void setCommissionRate(double rate){
commissionRate=(rate>0.0&&rate<1.0)?rate:0.0;
}
public double getCommissionRate(){
return commissionRate;
}
public void setGrossSales(double sales){
grossSales=sales<0.0?0.0:sales;
}
public double getGrossSales(){
return grossSales;
}
public double earnings(){
return getCommissionRate()*getGrossSales();
}
public String toString(){
return "\n代理人:"+super.toString();
}
}
*************************************************************
public class HourlyEmployee extends Employee{
private double wage;
private double hours;
public HourlyEmployee(String first,String last,String socialSecurityNumber,double hourlyWage,double hourlyWorked){
super(first,last,socialSecurityNumber);
setWage(hourlyWage);
setHours(hourlyWorked);
}
public void setWage(double wageAmount){wage=wageAmount<0.0?0.0:wageAmount;}
public double getWage(){return wage;}
public void setHours(double hoursWorked){hours=(hoursWorked>=0.0&&hoursWorked<=168.0)?hoursWorked:0.0;
}
public double getHours(){return hours;}
public double earnings(){
if(hours<=40)
return wage*hours;
else
return 40*wage+(hours-40)*wage*1.5;
}
public String toString