Java Reference
In-Depth Information
There are four states:
1.
START: Enter customer ID
2.
PIN: Enter PIN
3.
ACCOUNT: Select account
4.
TRANSACT: Select transaction
To understand how to move from one state to the next, it is useful to draw a state
diagram ( Figure 10 ). The UML notation has standardized shapes for state diagrams.
Draw states as rectangles with rounded corners. Draw state changes as arrows, with
labels that indicate the reason for the change.
The user must type a valid customer number and PIN. Then the ATM can ask the
bank to find the customer. This calls for a select customer method. It collaborates
with the bank, asking the bank for the customer that matches the customer number
and PIN. Next, there must be a select account method that asks the current
customer for the checking or savings account. Finally, the ATM must carry out the
selected transaction on the current account.
560
561
Of course, discovering these classes and methods was not as neat and orderly as it
appears from this discussion. When I designed these classes for this topic, it took
me several trials and many torn cards to come up with a satisfactory design. It is
also important to remember that there is seldom one best design.
This design has several advantages. The classes describe clear concepts. The
methods are sufficient to implement all necessary tasks. (I mentally walked through
Search WWH ::




Custom Search