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, ArrayList<Deduction> deductions) throws IllegalArgumentException
      Creates an Hourly Employee with an id, name, address, rate, and list of Deductions.
      Parameters:
      id - ID of the employee.
      name - Name of employee.
      address - Address of the employee.
      rate - Hourly rate of the employee.
      deductions - ArrayList of Deductions for 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 breaks down the payment for the Hourly employee.
      Specified by:
      paymentBreakdown in class Employee
      Returns:
      String that contains the hours, rate, gross pay, and net pay of the employee formatted nicely. The net pay is the gross pay minus the total deductions amount.