Package solution
Class Hourly
java.lang.Object
solution.Employee
solution.Hourly
Represents an Hourly employee with an hourly rate and hours.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
getPay()
Returns the gross pay of the Hourly Employee which is rate * hours.protected String
Returns a String that shows the payment breakdown for an Hourly employee with include their hourly rate, hours, and gross pay.void
setHours
(double hours) toString()
Returns a String representation of the Hourly Employee.Methods inherited from class solution.Employee
equals, formatLine, formatLine, generatePayStub
-
Constructor Details
-
Hourly
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. -
toString
Returns a String representation of the Hourly Employee. -
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 classEmployee
- Returns:
- String that contains the hours, rate, gross pay.
-