java.lang.Object
com.atmbanksimulator.UIModel
ATM Simulator - UI Model: Central Processor
The UIModel class acts as the brain of the ATM system, managing all UI logic,
session state, and user input processing. It receives instructions from the Controller,
maintains the current ATM state and, communicates with the Bank domain layer to execute banking operations,
and instructs the View to update the display.
- Version:
- 3.0
- Author:
- D'Souza, C. J.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the account details retrieved during processSettings().Returns the transaction history retrieved during processTransaction().voidInitialises the ATM to its default state, clearing all session data and resetting the display.voidHandles the Account Details button within settings.voidHandles the Balance button.voidHandles the Change Password button.voidHandles the Change Plan button.voidHandles the Change Withdrawal Limit button.voidClears the current numberPadInput and refreshes the display.voidHandles the Deposit button.voidprocessDeposit_PreDefined(String amount) Handles predefined deposit amount buttons (£5, £10, £20, £50, £100, £200).voidHandles the ENTER button press.voidHandles the EXIT button.voidHandles the Home button.voidprocessNumber(String numberOnButton) Handles numpad digit, decimal point, and backspace input.voidHandles the Settings button.voidCalled when the user clicks START.voidHandles the History button.voidHandles the Transfer button.voidprocessUnknownKey(String action) Handles any unrecognised button press.voidHandles the Withdraw button.voidupdatePlan(String type, String tier, String withdrawalLimit) Saves the updated plan selection and refreshes account details.
-
Constructor Details
-
UIModel
-
-
Method Details
-
initialise
public void initialise()Initialises the ATM to its default state, clearing all session data and resetting the display. -
processStart
public void processStart()Called when the user clicks START. Sets onATMScreen to true and initialises the session. -
processNumber
Handles numpad digit, decimal point, and backspace input. Validates decimal point usage based on the current state.- Parameters:
numberOnButton- the button label pressed
-
processClear
public void processClear()Clears the current numberPadInput and refreshes the display. -
processEnter
public void processEnter()Handles the ENTER button press. It's behaviour depends on the current state — validates account number, authenticates password, processes transactions, or confirms settings changes. -
processBalance
public void processBalance()Handles the Balance button. Displays the current account balance if logged in. -
processWithdraw
public void processWithdraw()Handles the Withdraw button. Transitions to the withdrawal input state if logged in. -
processDeposit
public void processDeposit()Handles the Deposit button. Transitions to the deposit input state if logged in. -
processDeposit_PreDefined
Handles predefined deposit amount buttons (£5, £10, £20, £50, £100, £200). Sets the numberPadInput directly without requiring manual numpad entry.- Parameters:
amount- the predefined amount as a string
-
processTransaction
public void processTransaction()Handles the History button. Fetches and stores transaction history if logged in. -
processTransfer
public void processTransfer()Handles the Transfer button. Transitions to the beneficiary account input state if logged in. -
getTransactionHistory
Returns the transaction history retrieved during processTransaction().- Returns:
- list of transaction records
-
processHome
public void processHome()Handles the Home button. Returns to the main logged in menu. -
processSettings
public void processSettings()Handles the Settings button. Transitions to the settings menu and fetches account details. -
processAccountDetails
public void processAccountDetails()Handles the Account Details button within settings. Transitions to the account details view. -
getAccountDetails
Returns the account details retrieved during processSettings().- Returns:
- list of account detail strings in a fixed order
-
processChangePassword
public void processChangePassword()Handles the Change Password button. Transitions to the current password verification state. -
processChangePlan
public void processChangePlan()Handles the Change Plan button. Transitions to the plan selection screen. -
updatePlan
Saves the updated plan selection and refreshes account details.- Parameters:
type- the new account type (Basic or Student)tier- the new account tier (Normal, Pro, or Prime)withdrawalLimit- the new withdrawal limit as a string
-
processChangeWithdrawalLimit
public void processChangeWithdrawalLimit()Handles the Change Withdrawal Limit button. Transitions to the limit input state. -
processExit
public void processExit()Handles the EXIT button. Shows a confirmation dialog — if confirmed, logs out and returns to the home screen. -
processUnknownKey
Handles any unrecognised button press.- Parameters:
action- the unrecognised action string
-