Class User

All Implemented Interfaces:
CSVEncodable
Direct Known Subclasses:
Applicant, HDBManager

public abstract class User extends CSVDecodable implements CSVEncodable
This class forms as the base of all user types. All of the above user types must extend this class, as it contains essential fields and common method declarations.
User types includes:
  • Applicant
  • HDB Officer
  • HDB Manager
Author:
Vincent Neo
  • Field Details

    • name

      private String name
      User's name.
    • nric

      private String nric
      User's NRIC number.
    • age

      private int age
      User's age.
    • maritalStatus

      private MaritalStatus maritalStatus
      User's martial status.
    • password

      private String password
      User's password.
    • listingSort

      private ListingSort listingSort
      User's listing sort type. This is used to sort the listings based on the user's preference.
    • listingFilter

      private ListingFilter listingFilter
      User's listing filter type. This is used to filter the listings based on the user's preference.
    • enquiriesSystem

      private EnquiriesSystem enquiriesSystem
      Enquiries system handles all enquiry needs of the user.
    • commonMenuOptions

      private static String[] commonMenuOptions
      Options that are common to all user types
  • Constructor Details

    • User

      public User(List<CSVCell> cells)
      Constructor that is intended for use by (@code CSVParser} class only.
      Parameters:
      cells - Represents a row of a CSV spreadsheet.
  • Method Details

    • getCommonMenuOptions

      public static int getCommonMenuOptions()
      Get number of common menu items
      Returns:
      number of common menu items
    • getName

      public String getName()
      Getter method returns the name of the user.
      Returns:
      Name of this user object.
    • getNric

      String getNric()
      Getter method for retrieving NRIC of a user.
      Returns:
      NRIC number of this user object.
    • getAge

      int getAge()
      Getter method for retrieving age of a user.
      Returns:
      Age of the user associated in this object.
    • getMaritalStatus

      MaritalStatus getMaritalStatus()
      Getter method for retrieving marital status of a user.
      Returns:
      Marital status of the user associated in this object.
    • getListingSort

      public ListingSort getListingSort()
      Getter method for retrieving listing sort of a user.
      Returns:
      Listing sort of the user associated in this object.
    • getListingFilter

      public ListingFilter getListingFilter()
      Getter method for retrieving listing filter of a user.
      Returns:
      Listing filter of the user associated in this object.
    • checkPassword

      boolean checkPassword(String password)
      Check if a user-provided password is correct for user. This method is for password validation purposes when going through a login flow. The password is not publicly accessible due to access control limits. Use this method instead to tell if a user should be allowed entry or not.
      Parameters:
      password - - The password to be tested.
      Returns:
      Whether if password is correct or not.
    • setPassword

      void setPassword(String password)
      For setting a new password. This method is intended to be used for users to set a new password.
      Parameters:
      password - - The new password to be saved.
    • setListingSort

      public void setListingSort(ListingSort listingFilter)
      For setting a new listing filter. This method is intended to be used for users to set a new listing filter.
      Parameters:
      listingFilter - - The new listing filter to be saved.
    • setListingFilter

      public void setListingFilter(ListingFilter listingFilter)
      For setting a new listing filter. This method is intended to be used for users to set a new listing filter.
      Parameters:
      listingFilter - - The new listing filter to be saved.
    • canApplyProject

      abstract boolean canApplyProject()
      For checking on whether a user should be allowed to apply for a project, based on eligibility criteria.
      Returns:
      if user's eligibility criteria matches, returns true, otherwise false.
    • getReadableTypeName

      abstract String getReadableTypeName()
      User-readable name for the type of user.
      Returns:
      the type of the user, such as "Applicant".
    • getMenu

      abstract ArrayList<String> getMenu()
      This method will prepare the list of tasks of which a user can perform. It can be expected that the contents of the list will be presented to the user to let them know what they can do. Subclasses must add on to the list by the superclass, rather than creating a new list.
      Returns:
      List of tasks that user can do using our BTO system.
    • getMenuWithScopedOptions

      ArrayList<String> getMenuWithScopedOptions(ScopedOption[] options)
      This method facilitates the generation of a menu that includes options specific to a certain user type. Child classes should call this method when overriding getMenu().
      Parameters:
      options - Scoped options that are only accessible depending on the user type.
      Returns:
      List of tasks that user can do using our BTO system.
    • print

      void print()
      Prints all fields of this user object, in a concise manner.
    • encode

      public String encode()
      Prepares text for CSV encoding purposes.
      Specified by:
      encode in interface CSVEncodable
      Returns:
      A string that is intended to represent a spreadsheet row, to be written in a CSV file.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object object)
      Checks if user is same, based on NRIC.
      Overrides:
      equals in class Object
    • nameEquals

      public boolean nameEquals(User user)
      Checks if name is equal between this and another user.
      Parameters:
      user - User to check against.
      Returns:
      true if both users are of the same name.
    • getEnquiriesSystem

      public EnquiriesSystem getEnquiriesSystem()
      Get the enquiries system object
      Returns:
      enquiries system object.
    • setEnquiriesSystem

      void setEnquiriesSystem(EnquiriesSystem enquiriesSystem)
      Assign a new enquiries system object, should only be handled by BTOManagementSystem.
      Parameters:
      enquiriesSystem - the new system to assign to, or null.