public class EmployeeDatabase
extends java.lang.Object
This class models some functions of an employee database. We have two classes: EmployeeDatabase and Employee. You only need to finish functions in this class, however you would have to refer to the functions in the other class as well. And, of course, fix the checkstyle errors.
Modifier and Type | Field | Description |
---|---|---|
java.util.List<Employee> |
employees |
List of employees.
|
Constructor | Description |
---|---|
EmployeeDatabase() |
Constructor which initializes the employees list.
|
Modifier and Type | Method | Description |
---|---|---|
int |
countEmployeesUnder(Employee employee) |
Count the number of employees under this manager.
|
int |
countManagersAbove(Employee employee) |
Count the number of managers above this employee.
|
Employee |
findManager(Employee employee) |
Returns the manager for the given employee.
|
static void |
main(java.lang.String[] unused) |
Main method for testing.
|
public java.util.List<Employee> employees
public EmployeeDatabase()
We suggest that you investigate the ArrayList class, which is one of the more useful built-in data structures in Java.
public Employee findManager(Employee employee)
employee
- the employee to return the manager forpublic int countManagersAbove(Employee employee)
Consider both a recursive and an iterative solution to this problem.
employee
- name of the employeepublic int countEmployeesUnder(Employee employee)
Consider both a recursive and an iterative solution to this problem.
employee
- name of the employeepublic static void main(java.lang.String[] unused)
You should understand, but do not need to modify, this function.
unused
- unused input arguments