Package com.manager
Class DB2024TEAM07_UserManager
java.lang.Object
com.manager.DB2024TEAM07_UserManager
This class manages user functionalities in the E-MATEASY application.
It provides methods for user login, logout, registration, information update,
and retrieval of user information for both general users and managers.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static DB2024TEAM07_Userprivate static DB2024TEAM07_UserDAO -
Constructor Summary
ConstructorsConstructorDescriptionConstructor that takes a DB2024TEAM07_UserDAO object as input. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAccountByManager(Scanner scanner) Allows managers to add new users.booleanaddUser(DB2024TEAM07_User user) Adds a new user to the database.static voiddeleteAccount(Scanner scanner) Allows users to delete their account after confirmation.voiddeleteAccountByManager(Scanner scanner) Allows managers to delete users.static voidDisplays a list of all users in the system.booleanAttempts to log in a user with the provided username and password.voidlogout()Logs out the currently logged in user by setting loggedInUser to null.voidsearchAccountByManager(Scanner scanner) Allows managers to search for users by ID.static voidsearchOtherUser(Scanner scanner) Allows users to search for another user by ID.static voidDisplays the information of the currently logged in user.static voidAllows users to update their information.voidupdateAccountByManager(Scanner scanner) Allows managers to update existing user information.
-
Field Details
-
userDAO
-
loggedInUser
-
-
Constructor Details
-
DB2024TEAM07_UserManager
Constructor that takes a DB2024TEAM07_UserDAO object as input.- Parameters:
userDAO- a DB2024TEAM07_UserDAO object for interacting with the user data access layer
-
-
Method Details
-
login
Attempts to log in a user with the provided username and password.- Parameters:
username- the username of the user trying to log inpassword- the password of the user trying to log in- Returns:
- true if the login is successful, false otherwise
-
logout
public void logout()Logs out the currently logged in user by setting loggedInUser to null. -
addUser
Adds a new user to the database.- Parameters:
user- a DB2024TEAM07_User object representing the new user- Returns:
- true if the user is added successfully, false otherwise
-
showMyInfo
public static void showMyInfo()Displays the information of the currently logged in user. -
searchOtherUser
Allows users to search for another user by ID.- Parameters:
scanner- a Scanner object to read user input
-
deleteAccount
Allows users to delete their account after confirmation.- Parameters:
scanner- a Scanner object to read user input
-
update
Allows users to update their information.- Parameters:
scanner- a Scanner object to read user input
-
displayAllUsers
public static void displayAllUsers()Displays a list of all users in the system. -
addAccountByManager
Allows managers to add new users.- Parameters:
scanner- a Scanner object to read user input
-
updateAccountByManager
Allows managers to update existing user information.- Parameters:
scanner- a Scanner object to read user input
-
searchAccountByManager
Allows managers to search for users by ID.- Parameters:
scanner- a Scanner object to read user input
-
deleteAccountByManager
Allows managers to delete users.- Parameters:
scanner- a Scanner object to read user input
-