## GUI Simulation of the ATM

The GUI simulation of the ATM is carried out by objects belonging to classes in package simulation. The overall manager is an object of class Simulation, which is created at program startup by either either the main program for the application version (in class ATMMain) or the applet object (belonging to class ATMApplet). The various objects in package atm.physical obtain access to this simulation manager object through the class method Simulation.getInstance(). The simulation manager object, in turn, has methods that correspond to the various actions that are simulated by the GUI.

The GUI is contained in a panel that is an instance of class GUI in the simulation package. The simulation manager creates an instance of this panel, which is then added to the main window of the application version or the applet panel of the applet version. The simulation manager forwards requests to simulate various events to this panel, which in turn may forward them to the appropriate component to carry them out. The GUI panel uses a CardLayout, and has four cards: the regular display of the ATM, the panel that requests the operator to enter the number of bills in the cash dispenser, the panel that asks the user to enter a card number, and the panel that displays the log. These four panels are implemented by objects of class ATMPanel, BillsPanel, CardPanel, and LogPanel, respectively.

Corresponding to each of the visible physical components of the ATM is a GUI component that simulates that physical component. These components are instances of class SimCardReader, SimCashDispenser, SimDisplay, SimKeyboard, SimEnvelopeAcceptor, SimOperatorPanel, and SimReceiptPrinter. (Note that the customer console is simulated by two GUI components - one simulating the display and one the keyboard.) There are no GUI simulations of the log and the network to the bank, since these are not directly visible to customers.

Finally, a class SimulatedBank simulates the bank itself. Messages to the bank are actually "sent" to an object of this class, which simulates the operation and creates an appropriate Status object to "send" back.

Source code for the various classes is accessible through the links below

Package | Class - source code
--- | ---
simulation | Simulation
simulation | GUI
| ATMPanel
| BillsPanel
| CardPanel
| LogPanel
simulation | SimCardReader
| SimCashDispenser
| SimDisplay
| SimEnvelopeAcceptor
| SimKeyboard
| SimOperatorPanel
| SimReceiptPrinter
simulation | SimulatedBank

###### Copyright © 2001 - Russell C. Bjork. Permission for non-commercial reproduction for educational use is hereby granted; all other rights are reserved.