/** Subclass of Employee for employees paid by the hour. Written January 25, 1997, by Kim Bruce. */ public class HourlyEmployee extends Employee{ // fields protected double hourlySalary; /** hourly wage of employee */ // constructors public HourlyEmployee (String emp_name, Date emp_bday, double hourlyWage) /** Construct hourly employee from name, birthday and hourly pay */ { super(emp_name,emp_bday); // Call constructor from superclass hourlySalary = hourlyWage; } // methods public void setHourlyPay(double new_salary) // post: hourly pay set to new_salary { hourlySalary = new_salary; } public double getWkPay() /** post: Returns weekly pay. */ // Note this override method in Employee { return (hourlySalary * 40.0); } /** This time we test with an hourly employee */ public static void main(String args[]){ // Create my birthday. Date kbday = new Date(1948,10,16); // Create new employee HourlyEmployee emp = new HourlyEmployee("Kim Bruce",kbday,5.25); // Print out info on the employee System.out.println("Today, the employee, "+emp.getName()+", is "+emp.getAge() +" years old."); System.out.println("He makes $"+emp.getWkPay()+" per week!"); } }