import java.util.*; /** * Representation of a manager. A manager is an exempty employee that also * records a list of other employees who he/she supervises * @author Hal Perkins * @version CSE143 Sp03 lecture example */ public class Manager extends ExemptEmployee { // additional instance variables private ArrayList employees; /** * Construct a new exempt employee with the give name, id number, weekly pay, * and an empty list of supervised employees * @param name Employee's name * @param id Employee's id number * @param pay Employee's weekly pay rate in dollars */ public Manager(String name, int id, double pay) { super(name, id, pay); employees = new ArrayList(); } /** * Add an employee to the list of employees supervised by this manager * @param newEmployee the new employee to be added * @return true if the addition succeeded, false if not */ public boolean addEmployee(Employee newEmployee) { return employees.add(newEmployee); } /** * Remove an employee from this manager's list of supervised employees * @param deletedEmployee employee to be removed * @return true if the deletion succeeded, false if not */ public boolean removeEmployee(Employee deletedEmployee) { return employees.remove(deletedEmployee); } /** * Return the employees supervised by this manager * @return a List of this manager's employees */ public List getEmployees() { return employees; } /** * Return the pay of this manager. Managers receive a 20% bonus for managing. * @return this manager's pay with management bonus */ public double getPay() { double basePay = super.getPay(); return basePay * 1.2; } /** * @return a string representation of this manager */ public String toString() { return "Manger(name = " + getName() + ", id = " + getId() + ", pay = " + getPay() + ", supervises " + employees.size() + " employee(s))"; } }