Class UIModel

java.lang.Object
com.atmbanksimulator.UIModel

public class UIModel extends Object

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 Details

    • UIModel

      public UIModel(Bank bank)
  • 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

      public void processNumber(String numberOnButton)
      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

      public void processDeposit_PreDefined(String amount)
      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

      public ArrayList<ArrayList<String>> 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

      public ArrayList<String> 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

      public void updatePlan(String type, String tier, String withdrawalLimit)
      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

      public void processUnknownKey(String action)
      Handles any unrecognised button press.
      Parameters:
      action - the unrecognised action string