Class Employee.EmployeeData
java.lang.Object
Employee.EmployeeData
- Direct Known Subclasses:
Tables.TableData
The Employee.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 Employee.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.Returns a formatted String of all schedule options stored in the scheduleOptions ArrayList.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 section information.void
remEmployee
(String name) Removes an employee from the employeeData HashMap.void
remScheduleOptions
(int schedule) Removes a schedule from the scheduleOptions ArrayList.searchEmployee
(String name) Searches for an employee's data in the employeeData HashMap.
-
Constructor Details
-
Employee.EmployeeData
public Employee.EmployeeData()The default constructor for the Employee.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.
-
remScheduleOptions
public void remScheduleOptions(int schedule) Removes a schedule from the scheduleOptions ArrayList.- Parameters:
schedule
- The numerical representation of the schedule to be removed.
-
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 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 if found, otherwise a message that the employee was not found
-
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 section information.- Returns:
- A String containing the formatted section information.
-