Class BankAccount

java.lang.Object
makingtransactions.bankaccounts.BankAccount
Direct Known Subclasses:
JointAccount, SingleAccount

public abstract class BankAccount extends Object
An abstract bank account class for creating different kinds of bank accounts.
  • Constructor Details

    • BankAccount

      public BankAccount(double balance, String accountName, String currency, int transitNumber, int institutionNumber, int accountNumber)
      Create a bank account with a balance.
      Parameters:
      balance - The balance of the account.
      accountName - The name of the account.
      currency - The type of currency.
      transitNumber - The transit number.
      institutionNumber - The institution number.
      accountNumber - The account number.
    • BankAccount

      public BankAccount(String accountName, String currency, int transitNumber, int institutionNumber, int accountNumber)
      Create a bank account without a balance.
      Parameters:
      accountName - The name of the account.
      currency - The type of currency.
      transitNumber - The transit number.
      institutionNumber - The institution number.
      accountNumber - The account number.
  • Method Details

    • getBalance

      public double getBalance()
      Get the balance of the bank account.
      Returns:
      The balance of the account.
    • setBalance

      public void setBalance(double balance) throws IllegalArgumentException
      Set the balance of the bank account.
      Parameters:
      balance - The balance of the account.
      Throws:
      IllegalArgumentException - If attempting to create a negative balance.
    • getCurrency

      public String getCurrency()
      Get the currency on the bank account.
      Returns:
      The currency on the account.
    • setCurrency

      public void setCurrency(String currency)
      Set the currency on the bank account.
      Parameters:
      currency - The type of currency.
    • getAccountName

      public String getAccountName()
      Get the name of the bank account.
      Returns:
      The name of the account.
    • setAccountName

      public void setAccountName(String accountName)
      Set the name of the bank account.
      Parameters:
      accountName - The name of the account.
    • getTransactions

      public ArrayList<Transaction> getTransactions()
      Get an ArrayList of transactions.
      Returns:
      An ArrayList of Transaction instances/objects.
    • addTransaction

      public void addTransaction(Transaction transaction) throws NegativeBalanceException
      Add a transaction to the bank account.
      Parameters:
      transaction - The transaction to be added.
      Throws:
      NegativeBalanceException - If the credit on the transaction is bigger than the account balance.
    • getTransitNumber

      public int getTransitNumber()
      Get the transit number on the bank account.
      Returns:
      The transit number on the account.
    • setTransitNumber

      public void setTransitNumber(int transitNumber)
      Set the transit number on the bank account.
      Parameters:
      transitNumber - The transit number on the account.
    • getInstitutionNumber

      public int getInstitutionNumber()
      Get the institution number on the bank account.
      Returns:
      The institution number on the account.
    • setInstitutionNumber

      public void setInstitutionNumber(int institutionNumber)
      Set the institution number on the bank account.
      Parameters:
      institutionNumber - The institution number on the account.
    • getAccountNumber

      public int getAccountNumber()
      Get the account number for the bank account.
      Returns:
      The account number for the account.
    • setAccountNumber

      public void setAccountNumber(int accountNumber)
      Set the account number for the bank account.
      Parameters:
      accountNumber - The account number.
    • toString

      public String toString()
      Overrides:
      toString in class Object