Question
Payroll System - Phase 2 ***Include javadoc comments for all new methods added to the project.*** Employee class: Modification 1: In the first constructor, make
Payroll System - Phase 2
***Include javadoc comments for all new methods added to the project.***
Employee class:
Modification 1: In the first constructor, make a copy of the paychecks parameter before using it to set the listOfPaychecks instance variable.
Modification 2: In the copy constructor, make a copy of employeeObject.listOfPaychecks before using it to set the listOfPaychecks instance variable.
Modification 3: In the setListOfPaychecks method, make a copy of the paychecks parameter before using it to set the listOfPaychecks instance variable.
Modification 4: In the getListOfPaychecks method, return a copy of the listOfPaychecks instance variable.
Modification 5: Provide an implementation for the equals method such that it compares the value of the firstName and lastName instance variables of the two objects. In other words, two Employee objects are considered equal if they have the same value for the firstName and lastName fields.
The following is the method signature:
Modification 6: Make the class implement the Comparable
Modification 7: Provide an implementation for the compareTo method such that it compares the value of the lastName instance variable of the two objects. If the lastName variable of the calling object is greater, it returns a positive number, if its smaller it returns a negative number, and if they both have the same value, the method then compares the firstName. If the firstName variable of the calling object is greater, it returns a positive number, if its smaller, it returns a negative number, else it returns 0.
Notes:
Use the compareTo method of the String class.
The following is the method signature:
Modification 8: Add an instance method called addPaycheck that does not return a value and has 1 parameter of type Paycheck. It adds a copy of the Paycheck parameter to the listOfPaychecks instance variable.
The following is the method signature:
Code that needs modification
Employee.java
package payrollsystem_phase1;
import java.util.ArrayList;
/** * The Employee class is an abstract class that holds general data about a company's * employee. Classes representing more specific types of employees should inherit * from this class. * * @author Mayelin */ public abstract class Employee { // instance variables private int employeeID; private String firstName; private String lastName; private ArrayList
}
public boolean equals (Object obj) // provide implementation
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started