java.lang.Object
com.atmbanksimulator.Bank
ATM Simulator - Bank: Bank Manager
The Bank class represents the bank system that manages account authentication and operations.
It acts as an intermediary between the UIModel and the SQLite database,
that is responsible for all data operations through BankAccount and SQLite.
- Version:
- 3.0
- Author:
- D'Souza, C. J.
-
Constructor Summary
ConstructorsConstructorDescriptionBank()Initialises the Bank and establishes a connection to the SQLite database. -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks whether the given input matches the logged in account's PIN.booleandeposit(float amount) Deposits the given amount into the logged in account.booleandeposit_transferred(String accountNumber_receiver, float amount) Credits the given amount into a receiver's account as part of a transfer.getAccountDetails(String accountNumber) Retrieves all account and customer details for the given account number.floatReturns the current balance of the logged in account.Retrieves the full name of the customer associated with the given account number.getTransactionHistory(String accountNumber) Retrieves the full transaction history for the given account number.floatgetWithdrawalLimit(String accountNumber) Retrieves the one-time withdrawal limit for the given account.booleanloggedIn()Checks whether a user is currently logged in.booleanAttempts to log in with the given account number and password.booleanlogin_AccountExist(String accountNumber) Checks whether an account with the given number exists in the database.voidlogout()Logs out the currently logged in account by setting loggedInAccount to null.setUpBankAccount(String accNumber, String accPasswd, float balance, SQLite sqlite) Method to create a new BankAccount2 instance.voidUpdates the PIN for the given account in both the database and the in memory account.voidupdatePlan(String accountNumber, String type, String tier, float withdrawalLimit) Updates the account type, tier, and withdrawal limit for the given account.voidupdateWithdrawalLimit(String accountNumber, float withdrawalLimit) Updates the one-time withdrawal limit for the given account.booleanwithdraw(float amount) Withdraws the given amount from the logged in account.booleanwithdraw_transferred(String accountNumber_receiver, float amount) Debits the given amount from the logged in account as part of a transfer.
-
Constructor Details
-
Bank
public Bank()Initialises the Bank and establishes a connection to the SQLite database.
-
-
Method Details
-
setUpBankAccount
public BankAccount setUpBankAccount(String accNumber, String accPasswd, float balance, SQLite sqlite) Method to create a new BankAccount2 instance.- Parameters:
accNumber- the account numberaccPasswd- the account PIN/passwordbalance- the current balancesqlite- the SQLite connection to use- Returns:
- a new BankAccount object
-
login_AccountExist
Checks whether an account with the given number exists in the database.- Parameters:
accountNumber- the account number to check- Returns:
- true if the account exists, false otherwise
-
login
Attempts to log in with the given account number and password. Logs out any previously logged in account before attempting login.- Parameters:
accountNumber- the account numberpassword- the PIN/password to verify- Returns:
- true if login is successful, false otherwise
-
logout
public void logout()Logs out the currently logged in account by setting loggedInAccount to null. -
loggedIn
public boolean loggedIn()Checks whether a user is currently logged in.- Returns:
- true if an account is logged in, false otherwise
-
deposit
public boolean deposit(float amount) Deposits the given amount into the logged in account.- Parameters:
amount- the amount to deposit- Returns:
- true if deposit was successful, false if not logged in
-
deposit_transferred
Credits the given amount into a receiver's account as part of a transfer.- Parameters:
accountNumber_receiver- the account number to receive the fundsamount- the amount to credit- Returns:
- true if successful, false if not logged in
-
getWithdrawalLimit
Retrieves the one-time withdrawal limit for the given account.- Parameters:
accountNumber- the account number to query- Returns:
- the withdrawal limit, or 0 if not logged in
-
updateWithdrawalLimit
Updates the one-time withdrawal limit for the given account.- Parameters:
accountNumber- the account number to updatewithdrawalLimit- the new withdrawal limit
-
withdraw
public boolean withdraw(float amount) Withdraws the given amount from the logged in account.- Parameters:
amount- the amount to withdraw- Returns:
- true if withdrawal was successful, false otherwise
-
withdraw_transferred
Debits the given amount from the logged in account as part of a transfer.- Parameters:
accountNumber_receiver- the receiver's account number (for transaction record)amount- the amount to debit- Returns:
- true if successful, false otherwise
-
getBalance
public float getBalance()Returns the current balance of the logged in account.- Returns:
- the balance, or -1 if not logged in
-
getName
Retrieves the full name of the customer associated with the given account number.- Parameters:
accountNumber- the account number to look up- Returns:
- the customer's full name in uppercase, or empty string if not logged in
-
getTransactionHistory
Retrieves the full transaction history for the given account number.- Parameters:
accountNumber- the account number to query- Returns:
- a list of transaction records, each as a list of strings, or null if not logged in
-
getAccountDetails
Retrieves all account and customer details for the given account number.- Parameters:
accountNumber- the account number to query- Returns:
- a list of detail strings in a fixed order, or null if not logged in
-
checkPin
Checks whether the given input matches the logged in account's PIN.- Parameters:
userInput- the PIN entered by the user- Returns:
- true if the PIN matches, false otherwise
-
updatePin
Updates the PIN for the given account in both the database and the in memory account.- Parameters:
accountNumber- the account number to updatenewPin- the new PIN string
-
updatePlan
Updates the account type, tier, and withdrawal limit for the given account.- Parameters:
accountNumber- the account to updatetype- the new account type (Basic or Student)tier- the new account tier (Normal, Pro, or Prime)withdrawalLimit- the new withdrawal limit
-