forked from rick2785/JavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHasCard.java
More file actions
48 lines (28 loc) · 957 Bytes
/
HasCard.java
File metadata and controls
48 lines (28 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
public class HasCard implements ATMState {
ATMMachine atmMachine;
public HasCard(ATMMachine newATMMachine){
atmMachine = newATMMachine;
}
public void insertCard() {
System.out.println("You can only insert one card at a time");
}
public void ejectCard() {
System.out.println("Your card is ejected");
atmMachine.setATMState(atmMachine.getNoCardState());
}
public void requestCash(int cashToWithdraw) {
System.out.println("You have not entered your PIN");
}
public void insertPin(int pinEntered) {
if(pinEntered == 1234){
System.out.println("You entered the correct PIN");
atmMachine.correctPinEntered = true;
atmMachine.setATMState(atmMachine.getHasPin());
} else {
System.out.println("You entered the wrong PIN");
atmMachine.correctPinEntered = false;
System.out.println("Your card is ejected");
atmMachine.setATMState(atmMachine.getNoCardState());
}
}
}