Package src

Class Customer


public class Customer extends Person
The Customer class represents a customer with multiple accounts. It extends the Person class and provides functionality to manage accounts, such as deposits, withdrawals, transfers, and viewing balances.
  • Constructor Details

    • Customer

      public Customer()
      Default constructor for the Customer class. Initializes an empty hashtable of accounts and sets the id to -1.
    • Customer

      public Customer(Dictionary<String,Account> accounts, int id, String firstName, String lastName, String dob, String address, String phone, int creditScore, int password)
      Constructs a Customer with specified account information and personal details.
      Parameters:
      accounts - The dictionary of the customer's accounts.
      id - The unique ID of the customer.
      firstName - The customer's first name.
      lastName - The customer's last name.
      dob - The customer's date of birth.
      address - The customer's address.
      phone - The customer's phone number.
  • Method Details

    • setAccounts

      public void setAccounts(Dictionary<String,Account> accounts)
      Sets the customer's accounts.
      Parameters:
      accounts - The dictionary of the customer's accounts.
    • setId

      public void setId(int id)
      Sets the customer's unique ID.
      Parameters:
      id - The unique ID of the customer.
    • setCreditScore

      public void setCreditScore(int creditScore)
      Sets the customer's credit score.
      Parameters:
      creditScore - The credit score of the customer.
    • setTransactions

      public void setTransactions(Transaction transactions)
      Sets the customer's transactions log so that entries can be added.
      Parameters:
      transactions - The object that will store the transaction logs.
    • setPassword

      public void setPassword(int password)
      Sets the customer's password.
      Parameters:
      password - The password for the customer.
    • getAccounts

      public Dictionary<String,Account> getAccounts()
      Returns the customer's accounts.
      Returns:
      A dictionary of the customer's accounts.
    • getId

      public int getId()
      Returns the customer's unique ID.
      Returns:
      The unique ID of the customer.
    • getPassword

      public int getPassword()
      Returns the customer's password.
      Returns:
      The password of the customer.
    • getCreditScore

      public int getCreditScore()
      Returns the customer's credit score.
      Returns:
      The credit score of the customer.
    • getTransactions

      public Transaction getTransactions()
      Returns the customer's transaction logs.
      Returns:
      The object storing the customers transaction logs.
    • addTransactionEntry

      public void addTransactionEntry(String entry)
    • findAccountType

      public String findAccountType(int number)
      Finds the type of account based on the account number.
      Parameters:
      number - The account number to find.
      Returns:
      The type of the account as a string, or null if not found.
    • getBalance

      public int getBalance()
      Returns the balance of the desired account. If the customer has more than one account, it prompts the user for the account type or number.
      Returns:
      The balance of the specified account or -1, -2, -3 for exit codes.
    • getBalance

      public int getBalance(String accountType)
      Returns the balance of the account of the specified type.
      Parameters:
      accountType - The type of the account.
      Returns:
      The balance of the account.
    • deposit

      public boolean deposit(String accountType, double amount)
      Deposits or withdraws money into/from the specified account.
      Parameters:
      accountType - The type of the account.
      amount - The amount to deposit (positive) or withdraw (negative).
      Returns:
      true if the transaction was successful, false otherwise.
    • deposit

      public boolean deposit(int accountNumber, double amount)
      Deposits or withdraws money into/from the specified account based on the account number.
      Parameters:
      accountNumber - The account number.
      amount - The amount to deposit or withdraw.
      Returns:
      true if the transaction was successful, false otherwise.
    • withdraw

      public boolean withdraw(String accountType, double amount)
      Withdraws money from the specified account.
      Parameters:
      accountType - The type of the account.
      amount - The amount to withdraw.
      Returns:
      true if successful, false otherwise.
    • withdraw

      public boolean withdraw(int accountNumber, double amount)
      Withdraws money from the specified account based on the account number.
      Parameters:
      accountNumber - The account number.
      amount - The amount to withdraw.
      Returns:
      true if successful, false otherwise.
    • transfer

      public boolean transfer(int source, int dest, double amount)
      Transfers money from one account to another within the same customer.
      Parameters:
      source - The source account number.
      dest - The destination account number.
      amount - The amount to be transferred.
      Returns:
      true if successful, false otherwise.
    • transfer

      public boolean transfer(String source, String dest, double amount)
      Transfers money from one account to another within the same customer.
      Parameters:
      source - The source account type.
      dest - The destination account type.
      amount - The amount to be transferred.
      Returns:
      true if successful, false otherwise.
    • pay

      public boolean pay(Customer customer, int source, int dest, double amount)
      Transfers a payment from one account of the current customer to another account of a different customer.
      Parameters:
      customer - The customer who will receive the payment.
      source - The source account number of the current customer.
      dest - The destination account number of the receiving customer.
      amount - The amount to be transferred.
      Returns:
      true if the payment was successful, false otherwise.
    • pay

      public boolean pay(Customer customer, String source, String dest, double amount)
      Transfers a payment from the current customer's account to another account belonging to a different customer.
      Parameters:
      customer - The customer receiving the payment.
      source - The type of the source account (e.g., "checking", "saving") from which the payment will be made.
      dest - The type of the destination account (e.g., "checking", "saving") to which the payment will be transferred.
      amount - The amount to be transferred.
      Returns:
      true if the payment was successful, false otherwise.