Package userservice

Class User

java.lang.Object
userservice.User

public final class User extends Object
A class for creating a user.
  • Constructor Details

    • User

      public User(String name, int age, int userId)
      Create a user.
      Parameters:
      name - The name of the user.
      age - The age of the user.
      userId - The user ID.
    • User

      public User(String name, int age, int userId, String email)
      Create a user with an email address.
      Parameters:
      name - The name of the user.
      age - The age of the user.
      userId - The user ID.
      email - An email address.
    • User

      public User(String name, int age, int userId, String email, String phoneNumber)
      Create a user with an phone number.
      Parameters:
      name - The name of the user.
      age - The age of the user.
      userId - The user ID.
      email - An email address.
      phoneNumber - A phone number.
  • Method Details

    • getName

      public String getName()
      Get the name of the user.
      Returns:
      The name of the user.
    • setName

      public void setName(String name)
      Set the name of the user.
      Parameters:
      name - The name of the user.
    • getAge

      public int getAge()
      Get the age of the user.
      Returns:
      The age of the user.
    • setAge

      public void setAge(int age) throws IllegalArgumentException
      Set the age of the user.
      Parameters:
      age - The age of the user.
      Throws:
      IllegalArgumentException - If age is 0 or below.
    • incrementAge

      public void incrementAge()
      Increment the age of the user by one.
    • getUserId

      public int getUserId()
      Get the ID of the user.
      Returns:
      The ID of the user.
    • setUserId

      public void setUserId(int userId)
      Set the ID of the user.
      Parameters:
      userId - The ID of the user.
    • getBankAccounts

      public ArrayList<BankAccount> getBankAccounts()
      Get the ArrayList of bank accounts from a user.
      Returns:
      An ArrayList of BankAccount classes.
    • addBankAccount

      public void addBankAccount(BankAccount bankAccount)
      Give the user a bank account.
      Parameters:
      bankAccount - The bank account to be added.
    • removeBankAccount

      public void removeBankAccount(BankAccount bankAccount)
      Remove a bank account from the user.
      Parameters:
      bankAccount - The bank account to be removed.
    • addEmail

      public void addEmail(String email)
      Add an email to the ArrayList of email addresses
      Parameters:
      email - The email to be added.
    • removeEmail

      public void removeEmail(String email)
      Remove an email address from the user.
      Parameters:
      email - The email to be removed.
    • getEmailAddresses

      public ArrayList<String> getEmailAddresses()
      Get an ArrayList of email addresses linked to the user.
      Returns:
      An ArrayList of email addresses.
    • addPhoneNumber

      public void addPhoneNumber(String phoneNumber)
      Add a phone number to the user.
      Parameters:
      phoneNumber - The phone number to be added.
    • removePhoneNumber

      public void removePhoneNumber(String phoneNumber)
      Remove a phone number from the user.
      Parameters:
      phoneNumber - The phone number to be removed.
    • getPhoneNumbers

      public ArrayList<String> getPhoneNumbers()
      Get an ArrayList of phone numbers linked to the user.
      Returns:
      An ArrayList of phone numbers.
    • toString

      public String toString()
      Overrides:
      toString in class Object