Module sc2002_fypms
Package models

Class User

  • Direct Known Subclasses:
    Student, Supervisor

    public class User
    extends java.lang.Object
    The User 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
      The UserRole of the user.
      private java.lang.String userID
      The ID of the user.
    • Constructor Summary

      Constructors 
      Constructor Description
      User​(java.lang.String userID, java.lang.String name, java.lang.String email, java.lang.String password)
      Constructs a User object with given user ID, name, email, and password.
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • userID

        private java.lang.String userID
        The ID of the user.
      • password

        private java.lang.String password
        The password of the user.
      • name

        private java.lang.String name
        The name of the user.
      • email

        private java.lang.String email
        The email address 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 a User object with given user ID, name, email, and password.
        Parameters:
        userID - the ID of the user
        name - the name of the user
        email - the email address of the user
        password - 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
      • getRole

        public UserRole getRole()
        Returns the UserRole of the User.
        Returns:
        the UserRole
      • 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 change
        newPassword - the new password to set
        Returns:
        true if password change is successful, false otherwise