public class ATM
extends java.lang.Object
OfflineAccountProxy
and later written back to the central
host.Constructor and Description |
---|
ATM(CentralHost centralHost) |
Modifier and Type | Method and Description |
---|---|
int |
accountBalance()
Determine the balance of the current account.
|
void |
confiscateCard()
Confiscate an inserted card.
|
BankCard |
ejectCard()
Eject an inserted card
|
void |
enterPIN(int pin)
Enter the PIN the belongs to the currently inserted bank card into the
ATM.
|
void |
insertCard(BankCard card)
Insert the given card into the ATM.
|
void |
requestAccountStatement()
Request a printed account statement for the current account
|
void |
setOnline(boolean newOnline)
Switch the status of
this ATM to online or offline. |
int |
withdraw(int amount)
Try to withdraw
amount from the current account. |
public ATM(CentralHost centralHost)
public void setOnline(boolean newOnline)
this
ATM to online or offline.
Switching to online will make the terminal write back all buffered
transactions to the central host and remove all account proxies.
TODO: one of the places where both complete specification and
verification are non-trivialnewOnline
- true
iff the terminal is switched onlinepublic void insertCard(BankCard card)
card
- the card to be insertedpublic BankCard ejectCard()
public void confiscateCard()
public void enterPIN(int pin)
pin
- the PIN that is enteredpublic int accountBalance()
0
is returned
TODO: make online a precondition?public int withdraw(int amount)
amount
from the current account.
TODO: make specification stronger, say something about the return value?amount
- the amount that is supposed to be withdrawn0
)public void requestAccountStatement()