Java Reference
In-Depth Information
49
private int
customerNumber;
50
private int
pin;
51
private
BankAccount checkingAccount;
52
private
BankAccount savingsAccount;
53 }
The following class implements a console user interface for the ATM.
ch12/atm/ATMSimulator.java
1
import
java.io.IOException;
2
import
java.util.Scanner;
3
4 /**
5
A text-based simulation of an automatic teller machine.
6 */
7
public class
ATMSimulator
8 {
9
public static void
main(String[] args)
10 {
11 ATM theATM;
12
try
13 {
14 Bank theBank =
new
Bank();
15 theBank.readCustomers(
Ðcustomers.txtÑ
);
16 theATM =
new
ATM(theBank);
17 }
18
catch
(IOException e)
19 {
20 System.out.println(
ÐError opening
accounts file.Ñ
);
21
return
;
22 }
23
24 Scanner in =
new
Scanner(System.in);
25
26
while
(
true
)
27 {
28
int
state = theATM.getState();
29
if
(state == ATM.START)
30 {
569
570