Java Reference
In-Depth Information
The BankAccount class is our familiar class with methods to get the balance and
to deposit and withdraw money.
In this program there is nothing that distinguishes checking accounts from savings
accounts. The ATM does not add interest or deduct fees. Therefore, we decide not
to implement separate subclasses for checking and savings accounts.
Finally, we are left with the ATM class itself. An important notion of the ATM is
the state. The current machine state determines the text of the prompts and the
function of the buttons. For example, when you first log in, you use the A and B
buttons to select an account. Next, you use the same buttons to choose between
deposit and withdrawal. The ATM must remember the current state so that it can
correctly interpret the buttons.
559
560
Figure 10
State Diagram for the ATM Class
Search WWH ::




Custom Search