Class EmployeeDatabase


  • public class EmployeeDatabase
    extends java.lang.Object
    A class that implements a database of employees.

    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.

    See Also:
    Lab 10 Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      java.util.List<Employee> employees
      List of employees.
    • Constructor Summary

      Constructors 
      Constructor Description
      EmployeeDatabase()
      Constructor which initializes the employees list.
    • Field Detail

      • employees

        public java.util.List<Employee> employees
        List of employees.
    • Constructor Detail

      • EmployeeDatabase

        public EmployeeDatabase()
        Constructor which initializes the employees list.

        We suggest that you investigate the ArrayList class, which is one of the more useful built-in data structures in Java.

    • Method Detail

      • findManager

        public Employee findManager​(Employee employee)
        Returns the manager for the given employee.
        Parameters:
        employee - the employee to return the manager for
        Returns:
        the employee's manager
      • countManagersAbove

        public int countManagersAbove​(Employee employee)
        Count the number of managers above this employee.

        Consider both a recursive and an iterative solution to this problem.

        Parameters:
        employee - name of the employee
        Returns:
        the number of manager's above this employee
      • countEmployeesUnder

        public int countEmployeesUnder​(Employee employee)
        Count the number of employees under this manager.

        Consider both a recursive and an iterative solution to this problem.

        Parameters:
        employee - name of the employee
        Returns:
        the number of employees under this manager
      • main

        public static void main​(java.lang.String[] unused)
        Main method for testing.

        You should understand, but do not need to modify, this function.

        Parameters:
        unused - unused input arguments