Question: I have the following code: public class Employee { private String employeeNumber; private String name; private String department; private double salary; public Employee() { setEmployee(null,
I have the following code:
public class Employee {
private String employeeNumber; private String name; private String department; private double salary;
public Employee() { setEmployee(null, null, null, 0.0); }
public Employee(String employeeNumber, String name, String department, double salary) { setEmployee(employeeNumber, name, department, salary); }
public void setEmployee(String employeeNumber, String name, String department, double salary) { this.employeeNumber = employeeNumber; this.name = name; this.department = department; this.salary = salary; }
public String getEmployeeNumber() { return employeeNumber; }
public void setEmployeeNumber(String employeeNumber) { this.employeeNumber = employeeNumber; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public String getDepartment() { return department; }
public void setDepartment(String department) { this.department = department; }
public double getSalary() { return salary; }
public void setSalary(double salary) { this.salary = salary; }
@Override public String toString() { return String.format("%-6s%-25s%-15s%6.2f", employeeNumber, name, department, salary); }
boolean equals(Employee e) { return employeeNumber.equals(e.employeeNumber); }
int compareTo ( Employee e) { return employeeNumber.compareTo(e.employeeNumber); }
}
NOW I NEED TO MAKE A ANOTHER CLASS CALLED HumanResources with the following instructions,
Create a class to implement an ordered linked list of employees (increasing order of employee number), the HumanResources class.
Inside the HumanResources class you, create a private class to define a node object. It will have two private data members, one member for an employee object and one for the address on the next node (i.e. the link). You may define one or more constructor for the node class.
The HumanResources class will have one private data member:
first which will be an object of the node class. It will store the reference (address) of the first node in the list.
The HumanResources class will include the following instance methods:
public HumanResources() Zero-parameter constructor to initialize an empty list.
public HumanResources(HumanResources) Copy constructor to create a new object (linked list) identical in content to the given parameter.
public boolean isEmpty() Method that returns true if the list is empty and false otherwise.
public boolean addEmployee(Employee) Method that inserts a new employee in the list (in increasing order of employee number). It returns true if the employee was added to the list. It returns false if the employee is already in the list (same employee number).
public boolean deleteEmployee(String) Method to delete the employee with the given employee number from the list. It returns true if the employee was deleted. It returns false if the employee was not in the list.
public Employee findEmployee(String) Method that returns an employee object if the employee with the given number is found in the list. It returns null otherwise.
public boolean changeDepartment(String, String) For the given employee (first parameter), this method changes the department value to the given department (second parameter). It returns true if the department was successfully changed (employee was present in the list); it returns false otherwise.
public boolean adjustSalary (String, double ) For the given employee (first parameter), this method adjusts the salary value by adding the given amount (second parameter) to the existing salary; the amount given may be positive or negative. It returns true if the employee salary was adjusted; it returns false otherwise.
public String toString() Method that returns the content of the list, i.e. all the data for each employee on a separate line.
public String decreasingOrder() Method that returns the content of the list, i.e. all the data for each employee on a separate line but in decreasing order of employee number. The method should call a recursive method (private) to achieve this.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
