Java Reference
In-Depth Information
@param pin the PIN
of the current customer
*/
This description can be almost literally translated to Java instructions:
public void selectCustomer(int pin)
{
assert state == PIN;
currentCustomer =
theBank.findCustomer(customerNumber, pin);
if (currentCustomer == null)
state = START;
else
state = ACCOUNT;
}
We won't go through a method-by-method description of the ATM program. You
should take some time and compare the actual implementation against the CRC
cards and the UML diagram.
ch12/atm/ATM.java
1 /**
2
An ATM that accesses a bank.
3 */
4
public class
ATM
5 {
6 /**
7
Constructs an ATM for a given bank.
8 @param aBank
the bank to which this ATM connects
9 */
10
public
ATM(Bank aBank)
11 {
12 theBank = aBank;
13 reset();
14 }
15
16 /**
17
Resets the ATM to the initial state.
18 */
19
public void
reset()
20 {
564
565