-
Notifications
You must be signed in to change notification settings - Fork 0
/
WinCheck.java
67 lines (58 loc) · 2.18 KB
/
WinCheck.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
public class WinCheck {
Wheel[] wheelStore = new Wheel[3];
Wheel wheel0 = new Wheel();
Wheel wheel1 = new Wheel();
Wheel wheel2 = new Wheel();
public int winPayout (Wheel[] wheelList, boolean[] lockList, int[] speedList) {
String[][] resultList = new String[wheelList.length][];
int payout;
int length = wheelList.length;
for (int i = 0; i < length; i++) {
wheelStore[i] = wheelList[i];
}
for (int i = 0; i < length; i++) {
Wheel tempWheel = new Wheel();
tempWheel.setArray(wheelStore[i].getArray());
tempWheel.setSpeed(speedList[i]);
resultList[i] = tempWheel.wheelSpin(lockList[i]);
printResult(wheelList, resultList, speedList);
}
if ((resultList[0][1] == resultList[1][1]) && (resultList[1][1] == resultList[2][1])) {
payout = Integer.parseInt(resultList[1][1]);
}
else if ((resultList[0][0] == resultList[1][1]) && (resultList[1][1] == resultList[2][2])) {
payout = Integer.parseInt(resultList[1][1]);
}
else if ((resultList[0][2] == resultList[1][1]) && (resultList[1][1] == resultList[2][0])) {
payout = Integer.parseInt(resultList[1][1]);
}
else {
payout = 0;
}
return payout;
}
private void printResult(Wheel[] listWheels, String[][] getResults, int[] listSpeeds) {
for (int i = 0; i < listWheels.length; i++) {
Wheel tempWheel = new Wheel(listWheels[i].getArray(), listSpeeds[i]);
String[] tempArray = tempWheel.getArray();
System.out.print(tempArray[Integer.parseInt(getResults[i][0])] + "\t");
System.out.println("");
}
for (int i = 0; i < listWheels.length; i++) {
Wheel tempWheel = new Wheel(listWheels[i].getArray(), listSpeeds[i]);
String[] tempArray = tempWheel.getArray();
System.out.print(tempArray[Integer.parseInt(getResults[i][1])] + "\t");
System.out.println("");
}
for (int i = 0; i < listWheels.length; i++) {
Wheel tempWheel = new Wheel(listWheels[i].getArray(), listSpeeds[i]);
String[] tempArray = tempWheel.getArray();
if (Integer.parseInt(getResults[i][1]) < tempArray.length) {
System.out.print(tempArray[Integer.parseInt(getResults[i][2])] + "\t");
}
else {
System.out.print(tempArray[0] + "\t");
}
}
}
}