-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestClass.java
More file actions
84 lines (65 loc) · 2.16 KB
/
TestClass.java
File metadata and controls
84 lines (65 loc) · 2.16 KB
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
/*
* Created By: Chisa Fukutome
* Date Created: 10/13/2020
* Purpose: Exam 2
*/
public class TestClass {
public static void main(String[] args) {
char choice = ' ';
int eSizeP = 1, eSizeS = 3, playerChoice = 0, slotMachineChoice = 0, playCount = 0;
boolean canPlay, continueChoice;
Player[] playerArray = new Player[50];
SlotMachine[] slotMachineArray = new SlotMachine[50];
//set default player and slot machines
Methods.setADefaultPlayer(playerArray);
Methods.setDefaultMachines(slotMachineArray);
//main menu
do {
System.out.println();
choice = Methods.getAChoice();
switch(choice) {
//Add A Player
case 'P':
eSizeP = Methods.loadPlayer(playerArray, eSizeP);
break;
//Add A Slot Machine
case 'S':
eSizeS = Methods.loadSlotMachine(slotMachineArray, eSizeS);
break;
//Gamble
case 'G':
//ask user the choice of player
playerChoice = Methods.getPlayerChoice(playerArray, eSizeP);
//determine if the player have enough money (more than $1) to play slot machines
System.out.println();
canPlay = Methods.canPlay(playerArray, eSizeP, playerChoice);
//reset
playCount = 0;
continueChoice = true;
while(continueChoice) {
playCount++;
if(canPlay) {
if(playCount == 1) {
//choose a slot machine
slotMachineChoice = Methods.getSlotMachineChoice(slotMachineArray, eSizeS);
}
//play the slot machine
Methods.playSlotMachine(slotMachineArray, slotMachineChoice, playerArray, playerChoice);
//reset continueChoice to avoid infinitive while loop
continueChoice = false;
//ask user if he continues
continueChoice = Methods.askContinuePlay(slotMachineArray, slotMachineChoice, playerArray, playerChoice);
}
}//end while loop
break;
//Quit
case 'Q':
System.out.println("Thank you for using our program, bye!");
break;
default:
System.out.println("You entered an invalid value, try again.");
break;
}
}while(choice != 'Q');
}//end main
}//end TestClass