Package makingtransactions.bankaccounts
Class BankAccount
java.lang.Object
makingtransactions.bankaccounts.BankAccount
- Direct Known Subclasses:
JointAccount
,SingleAccount
An abstract bank account class for creating different kinds of bank accounts.
-
Constructor Summary
ConstructorsConstructorDescriptionBankAccount
(double balance, String accountName, String currency, int transitNumber, int institutionNumber, int accountNumber) Create a bank account with a balance.BankAccount
(String accountName, String currency, int transitNumber, int institutionNumber, int accountNumber) Create a bank account without a balance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addTransaction
(Transaction transaction) Add a transaction to the bank account.Get the name of the bank account.int
Get the account number for the bank account.double
Get the balance of the bank account.Get the currency on the bank account.int
Get the institution number on the bank account.Get an ArrayList of transactions.int
Get the transit number on the bank account.void
setAccountName
(String accountName) Set the name of the bank account.void
setAccountNumber
(int accountNumber) Set the account number for the bank account.void
setBalance
(double balance) Set the balance of the bank account.void
setCurrency
(String currency) Set the currency on the bank account.void
setInstitutionNumber
(int institutionNumber) Set the institution number on the bank account.void
setTransitNumber
(int transitNumber) Set the transit number on the bank account.toString()
-
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
Set the balance of the bank account.- Parameters:
balance
- The balance of the account.- Throws:
IllegalArgumentException
- If attempting to create a negative balance.
-
getCurrency
Get the currency on the bank account.- Returns:
- The currency on the account.
-
setCurrency
Set the currency on the bank account.- Parameters:
currency
- The type of currency.
-
getAccountName
Get the name of the bank account.- Returns:
- The name of the account.
-
setAccountName
Set the name of the bank account.- Parameters:
accountName
- The name of the account.
-
getTransactions
Get an ArrayList of transactions.- Returns:
- An ArrayList of Transaction instances/objects.
-
addTransaction
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
-