package ics125_example_02;
public class CommissionEmployee extends Employee {
private double grossSales;
private double commissionRate;
public CommissionEmployee(String firstName, String lastName,
double commissionRate) {
double grossSales;
super(firstName, lastName);
this.grossSales = grossSales;
this.commissionRate = commissionRate;
}
@Override
public float calculatePay() {
// return the biweekly earnings for a commission employee
/*
Confirm commission rate is between 0.0 and 1.0.
If the rate is not between 0.0 and 1.0, set the rate to zero.
Confirm the gross sales is larger than 0.0.
If the gross sales is less than 0, set the gross sales to zero.
Calculate the earnings to be the rate times the sales.
*/
}
} // end class CommissionEmployee
package ics125_example_02;
public class ICS125_Example_02 {
public static void main(String[] args) {
// track the total amount paid for all employees.
float total = 0;
Employee[] office = { new SalaryEmployee("Bill", "Brown", 2),
new CommissionEmployee("Sue", "Black", 1000, 0.1),
new CommissionEmployee("Pat", "Green", 2000, 0.2),
new SalaryEmployee("Amy", "Redd", 3)
};
System.out.printf("Payment this period:%n");
// Print for each employee:
Employee Bill Brown earns $250.00
etc.
sum up the total
System.out.printf("Total pay out is %7.2f%n", total);
}
} // end class ISC125_Example_02