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:

Payroll System - Phase 2 ***Include javadoc comments for all new methods

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:

added to the project.*** Company class: Modification 1: In the constructor, make

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.

a copy of the departments parameter before using it to set the

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 listOfDepartments = new ArrayList(); /** * This constructor sets the company's name and list of departments. * @param name Company's name. * @param departments List of departments in the company. */ public Company(String name, ArrayList departments) { companyName = name; listOfDepartments = departments; }

/** * 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 getListOfDepartments() { return listOfDepartments; }

/** * 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 departments) { listOfDepartments = departments; } /** * The toString method returns a string containing the company's data. * @return A String containing the Company's information: name and list of * departments. */ @Override public String toString() { String output = String.format("%-30s %s", "Company Name:", companyName ); if( listOfDepartments == null || listOfDepartments.isEmpty() ) output += "There are no departments in the company."; else { for( Department deptElement : listOfDepartments) output += " " + deptElement; } return output; } }

public void addDepartment (Department dept) // provide implementation

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!