Package Employee
Class EmployeeData
java.lang.Object
Employee.EmployeeData
The EmployeeData class represents a collection of employees' data, including their first and last names, positions,
section assignments, and schedules.
-
Constructor Summary
ConstructorsConstructorDescriptionThe default constructor for the EmployeeData class that initializes the employeeData HashMap, scheduleOptions ArrayList, and sections ArrayList with default data. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEmployee
(String name, String position, int schedule, int section) Adds an employee's data to the employeeData HashMap.void
addScheduleOptions
(String newSchedule) 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.getSchedule
(String name) Returns an employee's schedule number from the HashMap.Returns a formatted String of all schedule options stored in the scheduleOptions ArrayList.getSection
(String name) Returns an employee's section number from the HashMap.boolean
isEmployee
(String name) 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
remEmployee
(String name) Removes an employee from the employeeData HashMap.searchEmployee
(String name) Searches for an employee's data in the employeeData HashMap.int[]
sectionArray
(String name) Returns an employee's section from the HashMap as an Integer array containing table numbers.
-
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
Adds a schedule to the scheduleOptions ArrayList.- Parameters:
newSchedule
- The String text of the schedule to be added.
-
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
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
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 editednewName
- the new first and last name for the employeenewPosition
- the new position for the employeenewSchedule
- the new numerical representation of the schedule for the employeenewSection
- the new section of tables the employee is responsible for
-
searchEmployee
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
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
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
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
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 restoredoldName
- the old name of the employee before the backup was madenewName
- the new name of the employee after the backup was made
-
isEmployee
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
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
This method returns a formatted String containing the sections.- Returns:
- A String containing the formatted section information.
-