Package solution

Class Hourly


public class Hourly extends Employee
Represents an Hourly employee with an hourly rate and hours.
  • Constructor Details

    • Hourly

      public Hourly(int id, String name, String address, double rate) throws IllegalArgumentException
      Creates an Hourly Employee with an id, name, address and hourly rate.
      Parameters:
      id - ID of the employee.
      name - Name of employee.
      address - Address of the employee.
      rate - Hourly rate of the employee.
      Throws:
      IllegalArgumentException - if rate is less than or equal to 0.
  • Method Details

    • setHours

      public void setHours(double hours)
    • getPay

      public double getPay()
      Returns the gross pay of the Hourly Employee which is rate * hours.
      Specified by:
      getPay in class Employee
      Returns:
      Gross pay of the Employee.
    • toString

      public String toString()
      Returns a String representation of the Hourly Employee.
      Overrides:
      toString in class Employee
      Returns:
      String with the ID, name, address, type, rate, and hours of the Employee.
    • paymentBreakdown

      protected String paymentBreakdown()
      Returns a String that shows the payment breakdown for an Hourly employee with include their hourly rate, hours, and gross pay. The gross pay is obtained from getPay(). This should be formatted with formatLine.
      Specified by:
      paymentBreakdown in class Employee
      Returns:
      String that contains the hours, rate, gross pay.