Module Lunchify
Package jku.se

Class User

java.lang.Object
jku.se.User
Direct Known Subclasses:
Administrator

public class User extends Object
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 Details

    • User

      public User(String name, String email, String password, boolean isAdministrator)
      Constructs a new User with the given parameters.
      Parameters:
      name - the user's name
      email - the user's email
      password - the user's password
      isAdministrator - true if the user is an administrator; false otherwise
  • Method Details

    • getName

      public String getName()
    • getEmail

      public String getEmail()
    • getPassword

      public String getPassword()
    • isAdministrator

      public boolean isAdministrator()
    • login

      public void login()
      Logs the user in and writes a log message.
    • viewAllInvoices

      public List<Invoice> viewAllInvoices()
      Gets all invoices submitted by this user (fetched from the repository).
      Returns:
      a list of all invoices for the user
    • viewHistory

      public List<Invoice> viewHistory()
      Gets the invoice history (locally stored in the user object).
      Returns:
      a list of past invoices (local)
    • receiveNotification

      public void receiveNotification(String message)
      Sends an in-app notification to the user with the given message.
      Parameters:
      message - the message to send
    • setNotification

      public void setNotification(Notification notification)
      Sets the Notification object used by this user.
      Parameters:
      notification - the notification handler