Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am having troubles understanding what I have to do here. A solution will be mu

ID: 3745062 • Letter: I

Question

I am having troubles understanding what I have to do here. A solution will be much appreciated.

Important You should not solve this by thinking this is a stand-alone, one-shot problem. Think of this as a way to develop a class hierarchy that can be placed in a library and never be modified afterward to accommodate new user classes that might be developed. So, in wages.java we give you a class Employee, and subclasses ageEmployee, Manager, Programmer, salesperson, and SalesManager and ask you to write an EmployeeList container class that implements methods for the maintenance of a database of Employee objects. The properties that the Employeelist should have are described below. Your code should be designed in such a way that is does not break by adding, for example, a President class, or a part-time Worker Class, or a Student co-op class, or any other class of object that might be derived from one of the subclasses of the Employee class and added t the EmployeeList database. This is an exercise in polymorphism. virtual functions are one means that C++ and Java have to support polymorphism . Lab Problem: Create a class called Employeelist that is a container of objects of the following kind abstract class Employee String name; Employee 0 Employee (String nm) name-nm abstract double computePay) void display O f) void setHours (double hrs) t) void setsales (double sales) t) void setselary (double salary) System.out-println"NO!")) This class and subclasses of this class are contained in file Wages.java, which compiles correctly without the Employeelist class. You will add your implementation of the Employeelist class to this file, uncomment the code at the bottom of the file, and maybe modify some of the existing code to see it rurn. The EmployeeList class should provide the following methods: Employee find (String nm) that returns an object in the container whose name matches nm, or null if no such Employee is in the container; void setHours (String nm, double hrs) that invokes setHours(hrs) on the employee in the container whose name matches nm; void setsalary (String nm, double salary) that invokes setsalary(salery) on the employee in the container whose name matches nm; void setsales (String nm, double sales) that invokes setSales(sales) on the employee in the container whose name matches nm; double payroll) that computes the total payroll of all Employee objects in the container using the computePay) method of each; and void display() which invokes display() of each employee in the container.

Explanation / Answer

Please find the required definitions for methods asked in the question

public class EmployeeList extends Employee{

//list that stores all the employee details

ArrayList<Employee> employees = new ArrayList();

//find employee by name

Employee find(String nm){

for(int i=0;i<employees.size();i++){

if(employees.get(i).name.equals(nm))return employees.get(i);

}

return null;

}

//set hours fo rth eemployee

void setHours(String nm, double hrs){

for(int i=0;i<employees.size();i++){

if(employees.get(i).name.equals(nm))employees.get(i).setHours(hrs);

}

}

//set salary for the employee

void setSalary(String nm, double salary){

for(int i=0;i<employees.size();i++){

if(employees.get(i).name.equals(nm))employees.get(i).setSalary(salary);

}

}

//set sales for the employee

void setSales(String nm, double sales){

for(int i=0;i<employees.size();i++){

if(employees.get(i).name.equals(nm))employees.get(i).setSales(sales);

}

}

//calculation pay roll fro each employee

void Payroll(){

for(int i=0;i<employees.size();i++){

if(employees.get(i).name.equals(nm))employees.get(i).computePay();

}

}

//invoking display function of employee class for each employee

void display(){

for(int i=0;i<employees.size();i++){

if(employees.get(i).name.equals(nm))employees.get(i).diaplay();

}

}

}

Please comment if you need to implement the other inherited classes as well as that is not asked in the question