Question
Payroll System - Phase 2 ***Include javadoc comments for all new methods added to the project.*** Company class: Modification 1: In the constructor, make a
Payroll System - Phase 2
***Include javadoc comments for all new methods added to the project.***
Company class:
Modification 1: In the constructor, make a copy of the departments parameter before using it to set the listOfDepartments instance variable.
Modification 2: In the setListOfDepartments method, make a copy of the departments parameter before using it to set the listOfDepartments instance variable.
Modification 3: In the getListOfDepartments method, return a copy of the listOfDepartments instance variable.
Modification 4: Write a method called addDepartment, which doesnt return a value and has 1 parameter of type Department. It adds a copy of the dept parameter to the listOfDepartments instance variable.
The following is the method signature:
Modification 5: Write a method called addEmployeeToDepartment, which doesnt return a value and has 2 parameters, the first is of type int, and the second of type Employee. This method iterates through all the elements in the listOfDepartments instance variable looking for a Department whose departmentID is equal to the int value passed as the first argument. If it finds it, it adds to it a copy of the Employee object passed as the second argument.
Below is the method header:
Modification 6: Write a method called setDepartmentManager, which doesnt return a value and has 2 parameters, the first is of type int, and the second of type Manager. This method iterates through all the elements in the listOfDepartments instance variable looking for a Department whose departmentID is equal to the int value passed as the first argument. If it finds it, it calls the setDepartmentManager method on that object passing the manObject parameter.
Code that needs to be Modified:
Company.java
package payrollsystem_phase1;
import java.util.ArrayList;
/** * The Company class represents a company having multiple departments. * * @author Mayelin */ public class Company { // instance variables private String companyName; private ArrayList
/** * The getCompanyName method returns the company's name. * @return The company's name. */ public String getCompanyName() { return companyName; }
/** * The getDepartmentList method returns the company's list of departments. * @return The company's list of departments as an ArrayList of Department elements. */ public ArrayList
/** * The setCompanyName method sets the name for this company. * @param name The value to store in the name field for this company. */ public void setCompanyName(String name) { companyName = name; }
/** * The setDepartmentList method sets the list of departments for this company. * @param departments The value, as an ArrayList of Department elements, to store * in the list of departments field for this company. */ public void setListOfDepartments(ArrayList
public void addDepartment (Department dept) // 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