Question: Create a class called Department. A department should have the following four attributes: 1 . departmentName: the name of the department . 2 . capacity:

Create a class called Department. A department should have the following four attributes: 1. departmentName: the name of the department .2. capacity: a constant value to indicate the maximum number of employees that this department can hire. 3. numMember: an integer value to indicate the number of employees currently in this department. 4. roster: an array that holds all of the employee objects who work in this department. Tasks: 1. Add a constructor. 2. Add a get method for each attribute. 3. Add a method called add(Employee e) that can add an employee (can be a regular employee, an hourlyPaidEmployee, or an executive) to the department. Assign this department to the employee objects department attribute. Throw the IndexOutOfBoundsExecption if the number of employees has exceeded maximum capacity for the department. 4. Add a method called transfer(Department other, Employee e) that can transfer the given employee from the department to the other specified department. If the other department has reached its capacity limit, then throw the IllegalStateException. If the given employee is not in the department, then throw the NoSuchElementException. 5. Implement Iterable and Iterator interfaces. After you implement those two interfaces, you should be able to loop through each employee object in this department. Again, you may add additional private utility methods to facilitate your design. In Yourlastname_Yourfirstname_hw5 class, create two departments as shown below. Call each method to test its functionality. Department department1= new Department("IT",20); Department department2= new Department("HR",8); Create four employee objects: Employee e1= new Executive("Alex Smith",2020,5,100000); // username = asmith, id =20200001 Employee e2= new Employee("Adam Smith",2021,4,80000); // username = asmith2, id =20210001 Employee e3= new Employee("Allison Smith",2021,3,75000); // username = asmith3 id =20210002 Page |3 Employee e4= new HourlyPaidEmployee("Andrew Smith", 2021,3,20); // username = asmith4, id =20210003, hourlyPayRate =20 Add employee objects, e1 to department2. Add employee objects, e2, e3 and e4 to department1. Then transfer e4 from department1 to department2.

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 Programming Questions!