Package Employee

Class EmployeeData

java.lang.Object
Employee.EmployeeData

public class EmployeeData extends Object
The EmployeeData class represents a collection of employees' data, including their first and last names, positions, section assignments, and schedules.
  • Constructor Summary

    Constructors
    Constructor
    Description
    The default constructor for the EmployeeData class that initializes the employeeData HashMap, scheduleOptions ArrayList, and sections ArrayList with default data.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addEmployee(String name, String position, int schedule, int section)
    Adds an employee's data to the employeeData HashMap.
    void
    Adds a schedule to the scheduleOptions ArrayList.
    void
    editEmployee(String name, String newName, String newPosition, int newSchedule, int newSection)
    Edits an employee's data in the employeeData HashMap.
    void
    employeeRestore(String backupName, String oldName, String newName)
    Restores an employee's name from a backup and updates the employeeData map accordingly.
    Returns an employee's schedule number from the HashMap.
    Returns a formatted String of all schedule options stored in the scheduleOptions ArrayList.
    Returns an employee's section number from the HashMap.
    boolean
    Checks whether an employee with the specified name exists in the employeeData map.
    listEmployee(int criteria)
    This method returns a formatted String containing the employee information based on the given criteria.
    This method returns a formatted String containing the sections.
    void
    Removes an employee from the employeeData HashMap.
    Searches for an employee's data in the employeeData HashMap.
    int[]
    Returns an employee's section from the HashMap as an Integer array containing table numbers.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EmployeeData

      public EmployeeData()
      The default constructor for the EmployeeData class that initializes the employeeData HashMap, scheduleOptions ArrayList, and sections ArrayList with default data.
  • Method Details

    • addScheduleOptions

      public void addScheduleOptions(String newSchedule)
      Adds a schedule to the scheduleOptions ArrayList.
      Parameters:
      newSchedule - The String text of the schedule to be added.
    • getScheduleOptions

      public String getScheduleOptions()
      Returns a formatted String of all schedule options stored in the scheduleOptions ArrayList.
      Returns:
      A formatted String of all schedule options stored in the scheduleOptions ArrayList.
    • addEmployee

      public void addEmployee(String name, String position, int schedule, int section)
      Adds an employee's data to the employeeData HashMap.
      Parameters:
      name - The employee's first and last name.
      position - The employee's position.
      schedule - The numerical representation of the employee's schedule.
      section - The numerical representation of the section of tables the employee is responsible for.
    • remEmployee

      public void remEmployee(String name)
      Removes an employee from the employeeData HashMap.
      Parameters:
      name - The employee's first and last name
    • editEmployee

      public void editEmployee(String name, String newName, String newPosition, int newSchedule, int newSection)
      Edits an employee's data in the employeeData HashMap.
      Parameters:
      name - the employee's first and last name to be edited
      newName - the new first and last name for the employee
      newPosition - the new position for the employee
      newSchedule - the new numerical representation of the schedule for the employee
      newSection - the new section of tables the employee is responsible for
    • searchEmployee

      public String searchEmployee(String name)
      Searches for an employee's data in the employeeData HashMap.
      Parameters:
      name - the employee's first and last name to search for
      Returns:
      the employee's data in a formatted string if found, otherwise a message that the employee was not found
    • getSchedule

      public Integer getSchedule(String name)
      Returns an employee's schedule number from the HashMap.
      Parameters:
      name - the employee's first and last name to search for
      Returns:
      the employee's schedule number if found.
      Throws:
      RuntimeException - if the employee is not found in the HashMap data
    • getSection

      public Integer getSection(String name)
      Returns an employee's section number from the HashMap.
      Parameters:
      name - the employee's first and last name to search for
      Returns:
      the employee's section number if found.
      Throws:
      RuntimeException - if the employee is not found in the HashMap data
    • sectionArray

      public int[] sectionArray(String name)
      Returns an employee's section from the HashMap as an Integer array containing table numbers.
      Parameters:
      name - the employee's first and last name to search for
      Returns:
      the employee's tables in an integer array.
    • employeeRestore

      public void employeeRestore(String backupName, String oldName, String newName)
      Restores an employee's name from a backup and updates the employeeData map accordingly.
      Parameters:
      backupName - the name of the backup for the employee to be restored
      oldName - the old name of the employee before the backup was made
      newName - the new name of the employee after the backup was made
    • isEmployee

      public boolean isEmployee(String name)
      Checks whether an employee with the specified name exists in the employeeData map.
      Parameters:
      name - the name of the employee to check
      Returns:
      true if the employeeData map contains an entry with the specified name, false otherwise
    • listEmployee

      public String listEmployee(int criteria)
      This method returns a formatted String containing the employee information based on the given criteria.
      Parameters:
      criteria - An integer indicating the format of the employee information to be returned. 1 - Returns only the name of each employee. 2 - Returns the name, position, and section of each employee. 3 - Returns the name, position, section, and schedule of each employee.
      Returns:
      A String containing the formatted employee information based on the given criteria.
      Throws:
      IllegalStateException - if the given criteria is not 1, 2, or 3.
    • listSection

      public String listSection()
      This method returns a formatted String containing the sections.
      Returns:
      A String containing the formatted section information.