-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathImplementation.java
333 lines (198 loc) · 7.59 KB
/
Implementation.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Implementation {
public static Queue<Player> waitingPlayers = new LinkedList<Player>(); // Queue of Players not currently in game.
// Add initial queue elements from text
public static int opt2=0; // inputs
public Implementation() {
}
public static void implement(Scanner scan) {
boolean k = false;
try {
while (k == false) { // beginning of main menu
Dis.display1();
Mainpp.opt1 = scan.nextInt();
switch (Mainpp.opt1) {
case 1:
int gameIndex = -1;
Dis.displayGames();
boolean a = false;
while (a == false) { // checking for inputted game validity
System.out.println("Select a Game:");
String choice = scan.next();
int tracker = 0;
for (int i = 0; i < Mainpp.gameList.size(); i++) { // look for inputed game choice in the arrayList
// of Games
if (choice.equals(Mainpp.gameList.get(i).name)) { // inputted game is a valid game in arraylist
// of games in program
a = true;
gameIndex = i;
boolean z = false;
tracker++;
while (z == false) { // setting up game menu functionality
Dis.display2();
opt2 = scan.nextInt();
if (opt2 == 1) { // "Add Player to the Game"
try {
Mainpp.gameList.get(gameIndex).addPlayerFromQueue();
System.out.println("Adding Player to Game");
}
catch (IndexOutOfBoundsException e) {
System.out.println(
"Variable gameIndex was not altered after initialization: " + e);
}
}
else if (opt2 == 2) { // "Play one round" CREATE PLAYER MENU
Dis.playerOption();
int opt3 = scan.nextInt();
boolean not=false;
while(not) {
if (opt3 == 1)
{
opt121(scan,gameIndex);
}
else if (opt3==2) {//Multiple Bets
opt122(scan,gameIndex);
}
else if (opt3==3) {//Add more money to Existing Players
System.out.println(Mainpp.gameList.get(gameIndex).playersInGame.size());
for(int ko=0;ko<Mainpp.gameList.get(gameIndex).playersInGame.size();ko++) {
System.out.print("Would you like to add money?(y/n)-->");
String know=scan.next();
if (know.equalsIgnoreCase("y")) {
System.out.print("Money to add-->");
int addmoney=scan.nextInt();
Mainpp.gameList.get(gameIndex).playersInGame.get(ko).addMoney(addmoney);
System.out.println("Money is added");
}
else {
System.out.println("No money added");
}
}
}
else if(opt3==4) {// Skip the bet
System.out.println(Mainpp.gameList.get(gameIndex).playersInGame.size());
for(int ko=0;ko<Mainpp.gameList.get(gameIndex).playersInGame.size();ko++) {
System.out.print("Would you like to skip a bet?(y/n)-->");
String know=scan.next();
if (know.equalsIgnoreCase("y")) {
System.out.print("skipped");
}
else {
System.out.println("Wanna make a single or multiple bet(s/m)");
String kk=scan.next();
if(kk.equalsIgnoreCase("s")) {
opt121(scan,gameIndex);}
else
opt122(scan,gameIndex);
}
}
}
else if(opt3==5) {// return to game menu
not=false;
}
}
}
else if (opt2 == 3) { // "Game Status"
Mainpp.gameList.get(gameIndex).printPlayers();
System.out.println("House Money: $" + Mainpp.gameList.get(gameIndex).houseMoney);
for (int j = Mainpp.gameList.get(gameIndex).transactionLines.size()- 1; j > Mainpp.gameList.get(gameIndex).transactionLines.size() - 4; j--) {
System.out.println( Mainpp.gameList.get(gameIndex).transactionLines.get(i).toString());
}
}
else if (opt2 == 4) { // "Return to the main menu
z = true;
}
}
}
}
if (tracker == 0) { // execute if we cant find the
System.out.println("Game Choice not found, please select from the given list.");
}
}
break;
// invoke game selection
case 2:
System.out.println("Adding Player to the Queue.");
addPlayerToQueue();
// invoke add a new player to the list with the queue
break;
case 3:
k = true;
// terminate the program while displaying the complete information for each game
// to a new txt file
break;
default:
System.out.println("Invalid Input! Please Try again");
break;
}
}
}
catch(InputMismatchException e) {
System.out.println("Invalid Input. Please,Restart the game to Try Again-->");
}
}
public static void addPlayerToQueue() {
Scanner scan = new Scanner(System.in);
System.out.print(
"What kind of player would you like to add? (Input Number: Normal == 0, VIP == 1, SuperVIP == 2 )-->");
int type = scan.nextInt();
System.out.println("How much money does this player start with?");
int initialMoney = scan.nextInt();
if (type > 0) {
System.out.println("Enter a 4 digit ID number for you player:");
String idNumber = scan.nextLine();
System.out.println("Please Enter a First and Last Name:");
String fullName = scan.nextLine();
if (type == 1) {
Player p1 = new VIPPlayer(fullName, initialMoney, idNumber);
System.out.println("VIP Player Created and added to Queue");
}
if (type == 2) {
Player p2 = new SuperVIPPlayer(fullName, initialMoney, idNumber);
System.out.println("Super VIP Player Created and added to Queue");
}
}
else {
Player p3 = new NormalPlayer(initialMoney);
System.out.println("Normal Player Created and added to Queue");
}
}
public static void opt121(Scanner scan, int gameIndex) {
Dis.playerOption();
int opt3 = scan.nextInt();
if (opt3 == 1)
{
Dis.display3();
Wheel.betOptions();
if(Mainpp.gameList.get(gameIndex).playersInGame.size()==0) {
System.out.println("Error! No Players Added to the game");
}
for (int play = 0; play < Mainpp.gameList.get(gameIndex).playersInGame.size(); play++) {
System.out.println("Play");
Mainpp.gameList.get(gameIndex).playersInGame.get(play).makeBet(scan);
}
System.out.println("Finished ");
System.out.println("Spinning Wheel");
Wheel.spin();}
}
public static void opt122(Scanner scan,int gameIndex) {
Dis.display3();
Wheel.betOptions();
if(Mainpp.gameList.get(gameIndex).playersInGame.size()==0) {
System.out.println("Error! No Players Added to the game");
}
for (int play = 0; play < Mainpp.gameList.get(gameIndex).playersInGame.size(); play++) {
System.out.println("Play");
while(Dis.playAgain(scan)) {
Mainpp.gameList.get(gameIndex).playersInGame.get(play).makeBet(scan);
}
}
System.out.println("Finished ");
System.out.println("Spinning Wheel");
Wheel.spin();
}
}