import java.util.*; public class HourlyEmployee extends FullTimeEmployee implements Employee { protected int hoursWorked; protected double payRate; /** * Initializes this HourlyEmployee object to have an empty string for * the name, 0 for hours worked, 0.00 for the pay rate and 0.00 for * grossPay. * */ public HourlyEmployee() { hoursWorked = 0; payRate = 0.00; grossPay = 0.00; } // default constructor /** * Initializes this HourlyEmployee object’s name and gross pay from a * a specified String object, which consists of a name, hours worked and * pay rate, with at least one blank between each of those three * components. * * @param s - the String object from which this HourlyEmployee object * is initialized. * */ public HourlyEmployee (String s) { StringTokenizer tokens = new StringTokenizer (s); name = tokens.nextToken(); hoursWorked = Integer.parseInt (tokens.nextToken()); payRate = Double.parseDouble (tokens.nextToken()); grossPay = hoursWorked * payRate; } // constructor with string parameter /** * Determines if this HourlyEmployee object’s gross pay is greater than * a specified Employee object’s gross pay. * * @param otherEmployee - the specified Employee object whose * gross pay this HourlyEmployee object’s gross pay is compared to. * * @return true - if this HourlyEmployee object did not work any overtime, * otherEmployee is a FullTimeEmployee object, and this * HourlyEmployee object’s gross pay is greater than * otherEmployee’s gross pay. Otherwise, return false. * */ public boolean makesMoreThan (Employee otherEmployee) { final int MAX_NORMAL_HOURS = 40; return hoursWorked <= MAX_NORMAL_HOURS && super.makesMoreThan (otherEmployee); } // method makesMoreThan } // class HourlyEmployee