-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAirPort.java
55 lines (51 loc) · 1.7 KB
/
AirPort.java
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
49
50
51
52
53
54
55
public class AirPort extends Property {
public AirPort() {
super("Airport", 3);
}
public void buyTicket(Player player) throws LowBalance, WrongInput {
if (player.getBalance() < 50)
throw new LowBalance(player);
player.addBalance(-50);
System.out.println("Choose location to travel");
if (player.getIndex() == 3) System.out.println("11 or 20");
else if (player.getIndex() == 11) System.out.println("3 or 20");
else if (player.getIndex() == 20) System.out.println("3 or 11");
int inp = input.nextInt();
switch (inp) {
case 3 :
player.setIndex(3);
break;
case 11 :
player.setIndex(11);
break;
case 20 :
player.setIndex(20);
break;
default :
throw new WrongInput();
}
}
public void airport(Player currentPlayer) {
setIndex(currentPlayer.getIndex());
System.out.println("You are in Airport");
do {
Continue = true;
System.out.println("1-buy a ticket to travel 2-go on");
switch (input.nextInt()) {
case 1:
try {
buyTicket(currentPlayer);
} catch (LowBalance e) {
System.out.println(e.getMessage());
} catch (WrongInput e) {
Continue = false;
}
case 2:
break;
default:
Continue = false;
break;
}
} while (!Continue);
}
}