- java.lang.Object
-
- models.User
-
- Direct Known Subclasses:
Student
,Supervisor
public class User extends java.lang.Object
TheUser
class represents a user in the system. Users have a unique ID, a name, an email address, and a password. Each user also has a role, which determines their level of access to the system.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
email
The email address of the user.private java.lang.String
name
The name of the user.private java.lang.String
password
The password of the user.private UserRole
role
TheUserRole
of the user.private java.lang.String
userID
The ID of the user.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getEmail()
Returns the email address of the User.java.lang.String
getName()
Returns the name of the User.java.lang.String
getPassword()
Returns the password of the User.UserRole
getRole()
Returns the UserRole of the User.java.lang.String
getUserID()
Returns the user ID of the User.java.lang.Boolean
setPassword(java.lang.String oldPassword, java.lang.String newPassword)
Sets the password of the user.java.lang.Boolean
setRole(UserRole role)
Sets the UserRole of the User.
-
-
-
Constructor Detail
-
User
public User(java.lang.String userID, java.lang.String name, java.lang.String email, java.lang.String password)
Constructs aUser
object with given user ID, name, email, and password.- Parameters:
userID
- the ID of the username
- the name of the useremail
- the email address of the userpassword
- the password of the user
-
-
Method Detail
-
getUserID
public java.lang.String getUserID()
Returns the user ID of the User.- Returns:
- the user ID
-
getPassword
public java.lang.String getPassword()
Returns the password of the User.- Returns:
- the password
-
getName
public java.lang.String getName()
Returns the name of the User.- Returns:
- the name
-
getEmail
public java.lang.String getEmail()
Returns the email address of the User.- Returns:
- the email address
-
setRole
public java.lang.Boolean setRole(UserRole role)
Sets the UserRole of the User.- Parameters:
role
- the UserRole to set- Returns:
- true if UserRole is set successfully
-
setPassword
public java.lang.Boolean setPassword(java.lang.String oldPassword, java.lang.String newPassword)
Sets the password of the user. Validates if the oldPassword matches the currentPassword- Parameters:
oldPassword
- the old password to confirm the changenewPassword
- the new password to set- Returns:
- true if password change is successful, false otherwise
-
-