java.lang.Object
jku.se.User
- Direct Known Subclasses:
Administrator
The
User
class represents a user in the system, which can either be a regular user or an administrator.
A user has a name, email, password, and a role (administrator or not). Users can log in, view their invoices, receive notifications, and manage their preferences.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetEmail()
getName()
boolean
void
login()
Logs the user in and writes a log message.void
receiveNotification
(String message) Sends an in-app notification to the user with the given message.void
setNotification
(Notification notification) Sets the Notification object used by this user.Gets all invoices submitted by this user (fetched from the repository).Gets the invoice history (locally stored in the user object).
-
Constructor Details
-
User
Constructs a new User with the given parameters.- Parameters:
name
- the user's nameemail
- the user's emailpassword
- the user's passwordisAdministrator
-true
if the user is an administrator;false
otherwise
-
-
Method Details
-
getName
-
getEmail
-
getPassword
-
isAdministrator
public boolean isAdministrator() -
login
public void login()Logs the user in and writes a log message. -
viewAllInvoices
Gets all invoices submitted by this user (fetched from the repository).- Returns:
- a list of all invoices for the user
-
viewHistory
Gets the invoice history (locally stored in the user object).- Returns:
- a list of past invoices (local)
-
receiveNotification
Sends an in-app notification to the user with the given message.- Parameters:
message
- the message to send
-
setNotification
Sets the Notification object used by this user.- Parameters:
notification
- the notification handler
-