Question: FOR HW1 EMPLOYEE CLASS IT WAS THIS : SAMPLE OUTPUT FOR Q3 : Q3. Using class Employee you implemented in Homework 1, write a class

 FOR HW1 EMPLOYEE CLASS IT WAS THIS : SAMPLE OUTPUT FOR

FOR HW1 EMPLOYEE CLASS IT WAS THIS :

Q3 : Q3. Using class Employee you implemented in Homework 1, write

a class Department that keeps a record of the employees within the

SAMPLE OUTPUT FOR Q3 :

department in an array. It has the following instance variables: name maximum

Q3. Using class Employee you implemented in Homework 1, write a class Department that keeps a record of the employees within the department in an array. It has the following instance variables: name maximum number of employees (maxEmp) current number of employees (numEmp) Array of employees. This array is used to store current employees information This class should provide: A constructor to initialize the name of the department and the maximum number of employees and create an empty employees array. An addEmployee method that creates an employee and adds it to the employees array. (boolean addEmployee (String, int, double)). A search method that takes the id of the employee and return its index in the array employees. A shift method that takes one argument which specifies the starting index where the array element should be shifted. This method shifts an array starting at location i to the left by 1. (void shift (int)) A remove method that removes an employee with a specific id from employees' array and return his/her record if found, otherwise return null. Use the shift method. (Employee removeEmp(int)). A print method that prints the department name and all employees in a tabular format as shown in the sample output. Write a test program DepartmentTest. In the main do the following: Create a department object with name "Human Resources" and 3 as maximum number of employees. Display a menu of choice as in the sample output. The program should stop and exit when user enters 5. Check the sample output and follow it in your program. If the user choses 4 (exit), prints the time complexity for each method 5 public class Employee { dovou // private instance variables private String name; private int id; // for the civil ID private double baseSalary; private int year; // to specify years since employment Employee() { name = "New Employee"; id = 1; baseSalary = 1000; year = 0; } 7 8 9 10 11 12 13e 14 15 16 17 18 19 20 210 22 23 24 25 26 27 28 29 300 31 // A constructor that initializes an employee with name, ID, and a baseSalary public Employee(String name, int id, double baseSalary) { //super(); this.name = name; this.id = id; this.baseSalary = baseSalary; this.year = 1; } // The get and set methods for all instance variables public String getName() { return this.name; 33 134 35 36 37 138 39 400 41 42 1430 44 145 146 47 public void setName(String name) { this.name = name; } public int getId() { return this.id; } public void setId(int id) { this.id = id; } public double getBaseSalary() { return this.baseSalary; } public void setBaseSalary(double baseSalary) { this.baseSalary = baseSalary; } public int getYear() { return this.year; } public void setYear(int year) { this.year = year; } public void increaseYears() { this.year+=1;; 148 149 50 51 52 53 154 550 56 57 58 59 60 61 public double computeSalary() { return this.baseSalary = baseSalary + baseSalary * 0.1 * this.year; } Choose one of the following: 1) Add employee 2) Remove an employee 3) Print department info 4) Exit 1 Enter an employee id or -1 to stop: 123 Enter employee name: Ahmad Enter employee base Salary: 1500 Enter an employee id or -1 to stop: 132 Enter employee name: Sara Enter employee base Salary: 700 Enter an employee id or -1 to stop: 400 Enter employee name: May Enter employee base Salary: 1000 Enter an employee id or -1 to stop: 134 Sorry, the department reached its capacity of employees. Choose one of the following: 1) Add employee 2) Remove an employee 3) Print department info 4) Exit 3 Employees of department: Human Resources id name 123 Ahmad 132 Sara 400 May

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!