|
@@ -1,35 +1,110 @@
|
1
|
1
|
package io.zipcoder.casino;
|
2
|
2
|
|
3
|
3
|
|
|
4
|
+import io.zipcoder.casino.cardgames.BlackJack;
|
|
5
|
+import io.zipcoder.casino.cardgames.GoFish;
|
|
6
|
+import io.zipcoder.casino.dicegames.Craps;
|
|
7
|
+import io.zipcoder.casino.player.Player;
|
4
|
8
|
import io.zipcoder.casino.player.Players;
|
|
9
|
+import io.zipcoder.casino.utilities.Console;
|
5
|
10
|
import io.zipcoder.casino.utilities.Game;
|
6
|
11
|
|
7
|
12
|
public class Casino {
|
8
|
13
|
private Game game;
|
|
14
|
+ Players players = Players.getInstance();
|
|
15
|
+ Console console = new Console();
|
9
|
16
|
|
10
|
|
- public void main() {
|
|
17
|
+ public static void main(String[] args) {
|
|
18
|
+ Casino casino = new Casino();
|
|
19
|
+
|
|
20
|
+//before game
|
|
21
|
+ casino.enterPlayers();
|
|
22
|
+ //ADD LOOP
|
|
23
|
+ casino.chooseTable();
|
|
24
|
+
|
|
25
|
+//after game
|
|
26
|
+ casino.printBalance();
|
|
27
|
+ casino.bootPlayer();
|
11
|
28
|
}
|
12
|
29
|
|
13
|
|
- public Players enterPlayers() {
|
14
|
|
- return null;
|
|
30
|
+ public void enterPlayers() {
|
|
31
|
+ int numberOfPlayers = console.getIntegerInput("WELCOME TO EPSILON CASINO, CALLED \"ALMOST A CASINO\" ON YELP\n" +
|
|
32
|
+ "PLEASE ENTER A NUMBER OF PLAYERS.");
|
|
33
|
+ String playerNames = "";
|
|
34
|
+ for (int i = 1; i <= numberOfPlayers; i++) {
|
|
35
|
+ String nameOfPlayer = console.getStringInput("PLAYER " + i + ": WHAT IS YOUR NAME?\n");
|
|
36
|
+ players.addPlayer(new Player(nameOfPlayer));
|
|
37
|
+ playerNames += nameOfPlayer + ", ";
|
|
38
|
+ }
|
|
39
|
+ console.println(playerNames + "THANK YOU FOR JOINING US");
|
15
|
40
|
}
|
16
|
41
|
|
17
|
42
|
public void chooseTable() {
|
18
|
|
- // runs game.runGame(game);
|
19
|
|
- }
|
|
43
|
+
|
|
44
|
+ console.println("GAME LIST\n");
|
|
45
|
+ console.println("1. CRAPS\n");
|
|
46
|
+ console.println("2. BLACK JACK\n");
|
|
47
|
+ console.println("3. GO FISH\n");
|
|
48
|
+ console.println("CHOOSE TABLE\n");
|
|
49
|
+ Integer number=console.getIntegerInput("") ;
|
|
50
|
+ switch(number){
|
|
51
|
+ case 1:
|
|
52
|
+ console.println("WELCOME TO CRAPS\n") ;
|
|
53
|
+ game = new Craps();
|
|
54
|
+ break;
|
|
55
|
+ case 2:
|
|
56
|
+ console.println("WELCOME TO BLACK JACK\n") ;
|
|
57
|
+ game = new BlackJack();
|
|
58
|
+ break;
|
|
59
|
+ case 3:
|
|
60
|
+ console.println("WELCOME TO GO FISH\n");
|
|
61
|
+ game = new GoFish();
|
|
62
|
+ break;
|
|
63
|
+ }
|
|
64
|
+ }
|
20
|
65
|
|
21
|
66
|
public void confirmPlayers() {
|
|
67
|
+ boolean isConfirmed = false;
|
|
68
|
+ while(!isConfirmed){
|
|
69
|
+ console.println("Current Players: ");
|
|
70
|
+ for(Player player : players.getPlayers()){
|
|
71
|
+ console.println(player.getName());
|
|
72
|
+ }
|
|
73
|
+ Integer choice = console.getIntegerInput("Choose option:\n (1)Confirm Players\n (2)Add Player\n (3)Remove Player\n");
|
|
74
|
+ String name;
|
|
75
|
+ switch(choice){
|
|
76
|
+ case 1: isConfirmed = true;
|
|
77
|
+ break;
|
|
78
|
+ case 2: name = console.getStringInput("Enter name of player to add: ");
|
|
79
|
+ players.addPlayer(new Player(name));
|
|
80
|
+ break;
|
|
81
|
+ case 3: name = console.getStringInput("Enter name of player to remove: ");
|
|
82
|
+ for(Player player : players.getPlayers()){
|
|
83
|
+ if(player.getName() == name)
|
|
84
|
+ players.removePlayer(player);
|
|
85
|
+ }
|
|
86
|
+ break;
|
|
87
|
+ default: break;
|
|
88
|
+ }
|
|
89
|
+ }
|
22
|
90
|
}
|
23
|
91
|
|
24
|
92
|
public void bootPlayer() {
|
25
|
93
|
// If player balance is 0, player game over
|
|
94
|
+ for(Player player : players.getPlayers()) {
|
|
95
|
+ if(player.getChipBalance()<=0){
|
|
96
|
+ console.println(player.getName() + ", YOU ARE BROKE. GTFO, PEASANT.");
|
|
97
|
+ players.removePlayer(player);
|
|
98
|
+ }
|
|
99
|
+ }
|
26
|
100
|
}
|
27
|
101
|
|
28
|
102
|
public void printBalance() {
|
|
103
|
+ console.println("FYI guys:\n");
|
|
104
|
+ for (Player player : players.getPlayers()){
|
|
105
|
+ console.println(String.format(player.getName() + " has " + player.getChipBalance() + " chips.\n"));
|
|
106
|
+ }
|
29
|
107
|
}
|
30
|
108
|
|
31
|
|
- public static void main(String[] args) {
|
32
|
|
- System.out.println("Hello");
|
33
|
|
- }
|
34
|
109
|
|
35
|
110
|
}
|