Package sc2002.FCS1.grp2
Class User
Object
CSVDecodable
User
- All Implemented Interfaces:
CSVEncodable
- Direct Known Subclasses:
Applicant,HDBManager
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:
User types includes:
- Applicant
- HDB Officer
- HDB Manager
- Author:
- Vincent Neo
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intUser's age.private static String[]Options that are common to all user typesprivate EnquiriesSystemEnquiries system handles all enquiry needs of the user.private ListingFilterUser's listing filter type.private ListingSortUser's listing sort type.private MaritalStatusUser's martial status.private StringUser's name.private StringUser's NRIC number.private StringUser's password. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) abstract booleanFor checking on whether a user should be allowed to apply for a project, based on eligibility criteria.(package private) booleancheckPassword(String password) Check if a user-provided password is correct for user.encode()Prepares text for CSV encoding purposes.booleanChecks if user is same, based on NRIC.(package private) intgetAge()Getter method for retrieving age of a user.static intGet number of common menu itemsGet the enquiries system objectGetter method for retrieving listing filter of a user.Getter method for retrieving listing sort of a user.(package private) MaritalStatusGetter method for retrieving marital status of a user.getMenu()This method will prepare the list of tasks of which a user can perform.getMenuWithScopedOptions(ScopedOption[] options) This method facilitates the generation of a menu that includes options specific to a certain user type.getName()Getter method returns the name of the user.(package private) StringgetNric()Getter method for retrieving NRIC of a user.(package private) abstract StringUser-readable name for the type of user.booleannameEquals(User user) Checks if name is equal between this and another user.(package private) voidprint()Prints all fields of this user object, in a concise manner.(package private) voidsetEnquiriesSystem(EnquiriesSystem enquiriesSystem) Assign a new enquiries system object, should only be handled byBTOManagementSystem.voidsetListingFilter(ListingFilter listingFilter) For setting a new listing filter.voidsetListingSort(ListingSort listingFilter) For setting a new listing filter.(package private) voidsetPassword(String password) For setting a new password.toString()Methods inherited from class Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface CSVEncodable
sourceFileType
-
Field Details
-
name
User's name. -
nric
User's NRIC number. -
age
private int ageUser's age. -
maritalStatus
User's martial status. -
password
User's password. -
listingSort
User's listing sort type. This is used to sort the listings based on the user's preference. -
listingFilter
User's listing filter type. This is used to filter the listings based on the user's preference. -
enquiriesSystem
Enquiries system handles all enquiry needs of the user. -
commonMenuOptions
Options that are common to all user types
-
-
Constructor Details
-
User
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
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
Getter method for retrieving listing sort of a user.- Returns:
- Listing sort of the user associated in this object.
-
getListingFilter
Getter method for retrieving listing filter of a user.- Returns:
- Listing filter of the user associated in this object.
-
checkPassword
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
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
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
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, otherwisefalse.
-
getReadableTypeName
User-readable name for the type of user.- Returns:
- the type of the user, such as "Applicant".
-
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
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
Prepares text for CSV encoding purposes.- Specified by:
encodein interfaceCSVEncodable- Returns:
- A string that is intended to represent a spreadsheet row, to be written in a CSV file.
-
toString
-
equals
Checks if user is same, based on NRIC. -
nameEquals
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
Get the enquiries system object- Returns:
- enquiries system object.
-
setEnquiriesSystem
Assign a new enquiries system object, should only be handled byBTOManagementSystem.- Parameters:
enquiriesSystem- the new system to assign to, or null.
-