Package DatabaseItems

Class Account

java.lang.Object
DatabaseItems.Account
All Implemented Interfaces:
DatabaseItems

public class Account extends Object implements 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 Details

    • Account

      public Account(String name, String id, Role role, Gender gender, int age)
      Constructs an Account with the specified details.
      Parameters:
      name - the name of the account holder
      id - the unique identifier for the account
      role - the role of the account holder (e.g., ADMIN, USER)
      gender - the gender of the account holder
      age - the age of the account holder
    • Account

      public Account(String name, String id, String password, Role role, Gender gender, int age)
      Constructs an Account with specified details including a custom password.
      Parameters:
      name - the name of the account holder
      id - the unique identifier for the account
      password - the password for the account
      role - the role of the account holder (e.g., ADMIN, USER)
      gender - the gender of the account holder
      age - the age of the account holder
    • Account

      public Account(String... params)
      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

      public void deserialise(String... params)
      Deserializes account details from a string array.
      Specified by:
      deserialise in interface DatabaseItems
      Parameters:
      params - an array of strings containing account details in order: name, id, password, role, gender, age
    • serialise

      public String serialise()
      Serializes account details into a comma-separated string.
      Specified by:
      serialise in interface DatabaseItems
      Returns:
      a string representation of the account details
    • printItem

      public void printItem()
      Prints account details to standard output.
      Specified by:
      printItem in interface DatabaseItems
    • getName

      public String getName()
      Returns the name of the account holder.
      Returns:
      the name of the account holder
    • getid

      public String getid()
      Returns the unique identifier for the account.
      Returns:
      the unique identifier for the account
    • getpassword

      public String getpassword()
      Returns the password for the account.
      Returns:
      the password for the account
    • getrole

      public Role getrole()
      Returns the role of the account holder.
      Returns:
      the role of the account holder
    • getGender

      public Gender 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

      public void setName(String name)
      Sets a new name for the account holder.
      Parameters:
      name - new name for the account holder
    • setId

      public void setId(String id)
      Sets a new unique identifier for this account.
      Parameters:
      id - new unique identifier for this account
    • setPassword

      public void setPassword(String password)
      Sets a new password for this account.
      Parameters:
      password - new password for this account
    • setRole

      public void setRole(Role role)
      Sets a new role for this account.
      Parameters:
      role - new role for this account
    • setGender

      public void setGender(Gender gender)
      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

      public boolean checkPassword(String password)
      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.