|
@@ -1,5 +1,6 @@
|
1
|
1
|
package io.zipcoder.casino;
|
2
|
2
|
|
|
3
|
+import java.util.ArrayList;
|
3
|
4
|
import java.util.Scanner;
|
4
|
5
|
|
5
|
6
|
public class Yahtzee extends DiceGame implements Game{
|
|
@@ -17,12 +18,21 @@ public class Yahtzee extends DiceGame implements Game{
|
17
|
18
|
player1.getScoreSheet().getTotalScore();
|
18
|
19
|
}
|
19
|
20
|
|
20
|
|
- public void reRoll(){
|
21
|
|
-
|
22
|
|
- }
|
23
|
|
-
|
24
|
|
- public void stopRoll(){
|
|
21
|
+ public void reRoll(String diceToRoll){
|
25
|
22
|
|
|
23
|
+ String[] numbersString = diceToRoll.replace(",", "").split(" ");
|
|
24
|
+ ArrayList<Integer> numbers = new ArrayList<>();
|
|
25
|
+ for(String s: numbersString) {
|
|
26
|
+ numbers.add(Integer.parseInt(s));
|
|
27
|
+ }
|
|
28
|
+ for(Integer i : numbers) {
|
|
29
|
+ for(int j = 0; j < 5; j++) {
|
|
30
|
+ if(i == dicePlayer.getCup()[j].getValue()) {
|
|
31
|
+ dicePlayer.getCup()[j].roll();
|
|
32
|
+ break;
|
|
33
|
+ }
|
|
34
|
+ }
|
|
35
|
+ }
|
26
|
36
|
}
|
27
|
37
|
|
28
|
38
|
/**
|
|
@@ -55,7 +65,7 @@ public class Yahtzee extends DiceGame implements Game{
|
55
|
65
|
dicePlayer.printCup();
|
56
|
66
|
|
57
|
67
|
roundRoutine();
|
58
|
|
-
|
|
68
|
+ recordingScore();
|
59
|
69
|
}
|
60
|
70
|
|
61
|
71
|
}
|
|
@@ -114,21 +124,16 @@ public class Yahtzee extends DiceGame implements Game{
|
114
|
124
|
break;
|
115
|
125
|
|
116
|
126
|
case 2:
|
|
127
|
+ System.out.println("Which numbers would you like to reroll?");
|
|
128
|
+ String diceToRoll = scanner.next();
|
|
129
|
+ reRoll(diceToRoll);
|
|
130
|
+ dicePlayer.printCup();
|
117
|
131
|
break;
|
|
132
|
+
|
118
|
133
|
case 3:
|
119
|
134
|
break;
|
120
|
135
|
}
|
121
|
136
|
}
|
122
|
137
|
|
123
|
|
- //ask if they want to score, or roll again?
|
124
|
|
-
|
125
|
|
- //roll again if requested
|
126
|
|
-
|
127
|
|
- //continue to roll until no more rolls are left
|
128
|
|
-
|
129
|
|
- //ask user how they would like to score
|
130
|
|
-
|
131
|
|
- //calculate the users score
|
132
|
|
-
|
133
|
138
|
}
|
134
|
139
|
}
|