Package DatabaseItems
Class Account
java.lang.Object
DatabaseItems.Account
- All Implemented Interfaces:
DatabaseItems
Represents an account in the system.
This class implements the DatabaseItems interface and provides
functionalities to manage user account details such as name, ID,
password, role, gender, and age.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an Account by deserializing from a set of parameters.Constructs an Account with the specified details.Constructs an Account with specified details including a custom password. -
Method Summary
Modifier and TypeMethodDescriptionboolean
checkPassword
(String password) Checks if a given password matches this account's stored password.void
deserialise
(String... params) Deserializes account details from a string array.int
getAge()
Returns the age of the account holder.Returns the gender of the account holder.getid()
Returns the unique identifier for the account.getName()
Returns the name of the account holder.Returns the password for the account.getrole()
Returns the role of the account holder.void
Prints account details to standard output.Serializes account details into a comma-separated string.void
setAge
(int age) Sets a new age for this account.void
Sets a new gender for this account.void
Sets a new unique identifier for this account.void
Sets a new name for the account holder.void
setPassword
(String password) Sets a new password for this account.void
Sets a new role for this account.
-
Constructor Details
-
Account
Constructs an Account with the specified details.- Parameters:
name
- the name of the account holderid
- the unique identifier for the accountrole
- the role of the account holder (e.g., ADMIN, USER)gender
- the gender of the account holderage
- the age of the account holder
-
Account
Constructs an Account with specified details including a custom password.- Parameters:
name
- the name of the account holderid
- the unique identifier for the accountpassword
- the password for the accountrole
- the role of the account holder (e.g., ADMIN, USER)gender
- the gender of the account holderage
- the age of the account holder
-
Account
Constructs an Account by deserializing from a set of parameters.- Parameters:
params
- an array of strings containing account details in order: name, id, password, role, gender, age
-
-
Method Details
-
deserialise
Deserializes account details from a string array.- Specified by:
deserialise
in interfaceDatabaseItems
- Parameters:
params
- an array of strings containing account details in order: name, id, password, role, gender, age
-
serialise
Serializes account details into a comma-separated string.- Specified by:
serialise
in interfaceDatabaseItems
- Returns:
- a string representation of the account details
-
printItem
public void printItem()Prints account details to standard output.- Specified by:
printItem
in interfaceDatabaseItems
-
getName
Returns the name of the account holder.- Returns:
- the name of the account holder
-
getid
Returns the unique identifier for the account.- Returns:
- the unique identifier for the account
-
getpassword
Returns the password for the account.- Returns:
- the password for the account
-
getrole
Returns the role of the account holder.- Returns:
- the role of the account holder
-
getGender
Returns the gender of the account holder.- Returns:
- the gender of the account holder
-
getAge
public int getAge()Returns the age of the account holder.- Returns:
- the age of the account holder
-
setName
Sets a new name for the account holder.- Parameters:
name
- new name for the account holder
-
setId
Sets a new unique identifier for this account.- Parameters:
id
- new unique identifier for this account
-
setPassword
Sets a new password for this account.- Parameters:
password
- new password for this account
-
setRole
Sets a new role for this account.- Parameters:
role
- new role for this account
-
setGender
Sets a new gender for this account.- Parameters:
gender
- new gender for this account
-
setAge
public void setAge(int age) Sets a new age for this account.- Parameters:
age
- new age for this account
-
checkPassword
Checks if a given password matches this account's stored password.- Parameters:
password
- The password to check against.- Returns:
- true if passwords match; false otherwise.
-