java.lang.Object
com.example.cab302project.User
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetEmail()Gets the registered email address.doubleGets the latitude of the home location.doubleGets the longitude of the home location.Gets the account password.getPhone()Gets the registered phone number.Gets the unique username identifier for the account.Gets the user type role for permission handling.booleanChecks if the dark mode preference is enabled.booleanisPolice()Checks if the user has police-level permissions.voidsetDarkMode(boolean darkMode) Updates the user's preference for the dark mode UI theme.voidUpdates the registered email address.voidsetHomeLocation(double lat, double lon) Updates the user's home geographic coordinates using validation.voidsetPassword(String password) Updates the stored password hash.voidUpdates the registered phone number.
-
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- TheUserTypedefining the user's permissions (REGULAR or POLICE).
-
-
Method Details
-
getUsername
Gets the unique username identifier for the account.- Returns:
- The unique username associated with this account.
-
getPassword
Gets the account password.- Returns:
- The account's current password hash.
-
getEmail
Gets the registered email address.- Returns:
- The user's registered email address.
-
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
Gets the user type role for permission handling.- Returns:
- The
UserTypeof this account.
-
setPassword
Updates the stored password hash.- Parameters:
password- The hash of the new password to set for the account.
-
setEmail
Updates the registered email address.- Parameters:
email- The new email address to set for the account.
-
setPhone
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 byLoginControllerto determine which dashboard to load.- Returns:
- true if the user is a police officer; false otherwise.
-