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: departmentName: the name of the department capacity: a constant value to indicate the maximum number of employees that this department can hire. numMember: an integer value to indicate the number of employees currently in this department. roster: an array that holds all of the employee objects who work in this department. Tasks: Add a constructor. Add a get method for each attribute. Add a method called addEmployee 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. Add a method called transferDepartment 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. 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 YourlastnameYourfirstnamehw class, create two departments as shown below. Call each method to test its functionality. Department department new DepartmentIT; Department department new DepartmentHR; Create four employee objects: Employee e new ExecutiveAlex Smith",; username asmith, id Employee e new EmployeeAdam Smith",; username asmith id Employee e new EmployeeAllison Smith",; username asmith id Page Employee e new HourlyPaidEmployeeAndrew Smith", ; username asmith id hourlyPayRate Add employee objects, e to department Add employee objects, e e and e to department Then transfer e from department to department
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
