java.lang.Object
com.example.cab302project.User

public class User extends Object
Represents a user within the RADIUS system. This class stores profile information, account credentials, and user preferences. It distinguishes between regular citizens and police officers via the UserType enum.
  • Constructor Details

    • User

      public User(String username, String password, String email, String phone, double homeLatitude, double homeLongitude, boolean darkMode, UserType userType)
      Constructs a new User with full profile details.
      Parameters:
      username - The unique identifier for the user (cannot be changed after creation).
      password - The hash of the account's authentication password.
      email - The user's contact email address.
      phone - The user's 10-digit contact phone number.
      homeLatitude - The latitude of the user's default home location (-90 to 90).
      homeLongitude - The longitude of the user's default home location (-180 to 180).
      darkMode - The user's UI theme preference (true for dark mode).
      userType - The UserType defining the user's permissions (REGULAR or POLICE).
  • Method Details

    • getUsername

      public String getUsername()
      Gets the unique username identifier for the account.
      Returns:
      The unique username associated with this account.
    • getPassword

      public String getPassword()
      Gets the account password.
      Returns:
      The account's current password hash.
    • getEmail

      public String getEmail()
      Gets the registered email address.
      Returns:
      The user's registered email address.
    • getPhone

      public String getPhone()
      Gets the registered phone number.
      Returns:
      The user's registered phone number.
    • getHomeLatitude

      public double getHomeLatitude()
      Gets the latitude of the home location.
      Returns:
      The latitude coordinate of the user's home location.
    • getHomeLongitude

      public double getHomeLongitude()
      Gets the longitude of the home location.
      Returns:
      The longitude coordinate of the user's home location.
    • isDarkMode

      public boolean isDarkMode()
      Checks if the dark mode preference is enabled.
      Returns:
      true if the user has enabled dark mode; false otherwise.
    • getUserType

      public UserType getUserType()
      Gets the user type role for permission handling.
      Returns:
      The UserType of this account.
    • setPassword

      public void setPassword(String password)
      Updates the stored password hash.
      Parameters:
      password - The hash of the new password to set for the account.
    • setEmail

      public void setEmail(String email)
      Updates the registered email address.
      Parameters:
      email - The new email address to set for the account.
    • setPhone

      public void setPhone(String phone)
      Updates the registered phone number.
      Parameters:
      phone - The new phone number to set for the account.
    • setDarkMode

      public void setDarkMode(boolean darkMode)
      Updates the user's preference for the dark mode UI theme.
      Parameters:
      darkMode - The new UI theme preference.
    • setHomeLocation

      public void setHomeLocation(double lat, double lon)
      Updates the user's home geographic coordinates using validation.
      Parameters:
      lat - The new latitude coordinate.
      lon - The new longitude coordinate.
    • isPolice

      public boolean isPolice()
      Checks if the user has police-level permissions. Used primarily by LoginController to determine which dashboard to load.
      Returns:
      true if the user is a police officer; false otherwise.