import java.util.*; public class Boss extends Employee { Vector employees; public Boss(String _name, float _salary) { super(_name, _salary); leaf = false; employees = new Vector(); } //-------------------------------------- public Boss(Employee _parent, String _name, float _salary) { super(_parent, _name, _salary); leaf = false; employees = new Vector(); } //-------------------------------------- public boolean add(Employee e) throws NoSuchElementException { employees.add(e); return true; } //-------------------------------------- public void remove(Employee e) throws NoSuchElementException { employees.removeElement(e); } //-------------------------------------- public Enumeration subordinates () { return employees.elements (); } //-------------------------------------- public Employee getChild(String s) throws NoSuchElementException { Employee newEmp = null; if(getName().equals(s)) return this; else { boolean found = false; Enumeration e = subordinates(); while(e.hasMoreElements() && (! found)) { newEmp = (Employee)e.nextElement(); found = newEmp.getName().equals(s); if (! found) { if (! newEmp.isLeaf ()) { newEmp = newEmp.getChild(s); } else newEmp = null; found =(newEmp != null); } } if (found) return newEmp; else return null; } } //-------------------------------------- public float getSalaries() { float sum = salary; for(int i = 0; i < employees.size(); i++) { sum += ((Employee)employees.elementAt(i)).getSalaries(); } return sum; } }