Package username
Class Employee
java.lang.Object
username.Employee
Base abstract class for an Employee that contains
an id, name, address, and list of deductions.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
formatLine
(String type, double value) Generates a String that consists of a String and number with the correct formating.Generates a String that can be written to the paystub.int
getId()
getName()
abstract double
getPay()
Returns the gross pay for this Employeeprotected abstract String
Generates a String that can be added to the end of paystub String to show the breakdown of the payment.toString()
Returns a String representation of the Employee.protected double
Returns the total sum of the deductions.
-
Constructor Details
-
Employee
public Employee(int id, String name, String address, List<Deduction> deductions) throws IllegalArgumentException Creates a new Employee object with an ID, name, address and list of deductions.- Parameters:
id
- ID of the employeename
- Name of employeeaddress
- Address of the employeedeductions
- List of Deductions for the Employee- Throws:
IllegalArgumentException
- If id is less than or equal to zero, or name, address, or deductions are null.
-
-
Method Details
-
getId
public int getId() -
getName
-
getAddress
-
getPay
public abstract double getPay()Returns the gross pay for this Employee- Returns:
- Gross pay.
-
generatePayStub
Generates a String that can be written to the paystub.- Returns:
- String of information to be written to the paystub which include information about the Employee, list of Deductions sorted from largest to smallest, and a breakdown of the amount to be paid.
-
toString
Returns a String representation of the Employee. -
totalDeductions
protected double totalDeductions()Returns the total sum of the deductions.- Returns:
- Total sum of deductions.
-
paymentBreakdown
Generates a String that can be added to the end of paystub String to show the breakdown of the payment.- Returns:
- String that includes the gross and net pay of the employee, the employee type, and any other relevant information like number of hours for Hourly employees. The net pay is the gross pay for the pay period minus the total deductions amount.
-
formatLine
Generates a String that consists of a String and number with the correct formating.- Parameters:
type
- Type of the value.value
- Value to be formatted.- Returns:
- Formatted String with the correct spacing and decimal places.
-