Java Reference
In-Depth Information
53
Updates display message.
54 */
55
public void
showState()
56 {
57
int
state = theATM.getState();
58 pad.clear();
59
if
(state == ATM.START)
60 display.setText(
ÐEnter customer
number\nA = OKÑ
);
61
else if
(state == ATM.PIN)
62 display.setText(
ÐEnter PIN\nA = OKÑ
);
63
else if
(state == ATM.ACCOUNT)
64 display.setText(
ÐSelect Account\nÑ
65 +
ÐA = Checking\nB =
Savings\nC = ExitÑ
);
66
else if
(state == ATM.TRANSACT)
67 display.setText(
ÐBalance = Ñ
68 + theATM.getBalance()
69 +
Ð\nEnter amount and select
transaction\nÑ
70 +
ÐA = Withdraw\nB =
Deposit\nC = CancelÑ
);
71 }
72
73
private class
AButtonListener
implements
ActionListener
74 {
75
public void
actionPerformed(ActionEvent
event)
76 {
77
int
state = theATM.getState();
78
if
(state == ATM.START)
79 theATM.setCustomerNumber((
int
)
pad.getValue());
80
else if
(state == ATM.PIN)
81 theATM.selectCustomer((
int
)
pad.getValue());
82
else if
(state == ATM.ACCOUNT)
83 theATM.selectAccount(ATM.CHECKING);
84
else if
(state == ATM.TRANSACT)
85 {
86 theATM.withdraw(pad.getValue());
87 theATM.back();