Package Controllers
Class StaffManager
java.lang.Object
Controllers.StaffManager
The
StaffManager
class provides functionalities for managing staff accounts.
It allows adding, removing, editing, and displaying staff information based on various filters.-
Constructor Summary
ConstructorsConstructorDescriptionStaffManager
(AccountDatabase accountDatabase) Constructs aStaffManager
with the specified account database. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds a new staff member to the database.void
Displays all staff members who are doctors or pharmacists.void
displayStaffs
(FilterParam filter, int lowerBound, int upperBound) Displays all staff members filtered by age range.void
displayStaffs
(FilterParam filter, String param) Displays all staff members filtered by specified parameter and value.boolean
Edits the age of a staff member by user ID.boolean
editGender
(String userId, Gender gender) Edits the gender of a staff member by user ID.boolean
Edits the name of a staff member by user ID.boolean
editPassword
(String userId, String password) Edits the password of a staff member by user ID.getUserInfo
(String userId) Retrieves user information by user ID.boolean
removeStaff
(String userId) Removes a staff member from the database by user ID.
-
Constructor Details
-
StaffManager
Constructs aStaffManager
with the specified account database.- Parameters:
accountDatabase
- theAccountDatabase
used to manage staff accounts
-
-
Method Details
-
addStaff
Adds a new staff member to the database. -
removeStaff
Removes a staff member from the database by user ID.- Parameters:
userId
- the unique identifier of the user to be removed- Returns:
- true if the staff member was removed successfully; false if not found
- Throws:
Exception
- if trying to remove patients or admins
-
getUserInfo
Retrieves user information by user ID.- Parameters:
userId
- the unique identifier of the user whose information is to be retrieved- Returns:
- the
Account
object representing the user, or null if not found
-
editName
Edits the name of a staff member by user ID.- Parameters:
userId
- the unique identifier of the user whose name is to be editedname
- the new name for the user- Returns:
- true if the name was updated successfully; false if not found
-
editPassword
Edits the password of a staff member by user ID.- Parameters:
userId
- the unique identifier of the user whose password is to be editedpassword
- the new password for the user- Returns:
- true if the password was updated successfully; false if not found
-
editGender
Edits the gender of a staff member by user ID.- Parameters:
userId
- the unique identifier of the user whose gender is to be editedgender
- the new gender for the user- Returns:
- true if the gender was updated successfully; false if not found
-
editAge
Edits the age of a staff member by user ID.- Parameters:
userId
- the unique identifier of the user whose age is to be editedage
- the new age for the user- Returns:
- true if the age was updated successfully; false if not found
-
displayStaffs
Displays all staff members filtered by specified parameter and value.- Parameters:
filter
- parameter by which to filter staff members (e.g., ROLE or GENDER)param
- value used for filtering based on specified parameter
-
displayStaffs
Displays all staff members filtered by age range.- Parameters:
filter
- parameter by which to filter staff members, must be AGElowerBound
- lower bound of age range for filteringupperBound
- upper bound of age range for filtering
-
displayAllStaff
public void displayAllStaff()Displays all staff members who are doctors or pharmacists.
-