Fixed Game.java sameColor multiplier, tested in Java 8, works.
Cleaned up GameWheel sort and scramble code a bit.
This commit is contained in:
parent
fa8208a4f8
commit
e400aaed8b
1 changed files with 7 additions and 11 deletions
|
@ -28,7 +28,6 @@ public class GameWheel
|
||||||
public void scramble()
|
public void scramble()
|
||||||
{
|
{
|
||||||
//Implement the scramble method here
|
//Implement the scramble method here
|
||||||
ArrayList<Slice> newSlices = new ArrayList<>();
|
|
||||||
ArrayList<Slice> redStuff = new ArrayList<>(shuffle(colorSplit(slices, "red")));
|
ArrayList<Slice> redStuff = new ArrayList<>(shuffle(colorSplit(slices, "red")));
|
||||||
ArrayList<Slice> blueStuff = new ArrayList<>(shuffle(colorSplit(slices, "blue")));
|
ArrayList<Slice> blueStuff = new ArrayList<>(shuffle(colorSplit(slices, "blue")));
|
||||||
ArrayList<Slice> blackStuff = new ArrayList<>(shuffle(colorSplit(slices, "black")));
|
ArrayList<Slice> blackStuff = new ArrayList<>(shuffle(colorSplit(slices, "black")));
|
||||||
|
@ -37,18 +36,17 @@ public class GameWheel
|
||||||
int redCount = 0;
|
int redCount = 0;
|
||||||
for (int i = 0; i < 20; i++){
|
for (int i = 0; i < 20; i++){
|
||||||
if (i % 5 == 0){
|
if (i % 5 == 0){
|
||||||
newSlices.add(blackStuff.get(blackCount));
|
slices.add(blackStuff.get(blackCount));
|
||||||
blackCount++;
|
blackCount++;
|
||||||
} else if (i % 2 == 0){
|
} else if (i % 2 == 0){
|
||||||
newSlices.add(blueStuff.get(blueCount));
|
slices.add(blueStuff.get(blueCount));
|
||||||
blueCount++;
|
blueCount++;
|
||||||
} else {
|
} else {
|
||||||
newSlices.add(redStuff.get(redCount));
|
slices.add(redStuff.get(redCount));
|
||||||
redCount++;
|
redCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
slices.subList(0, 20).clear();
|
slices.subList(0, 20).clear();
|
||||||
slices.addAll(newSlices);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,7 +59,6 @@ public class GameWheel
|
||||||
- Need to use colorSplit(ArrayList<Slice>) and sort(ArrayList<Slice>) to sort
|
- Need to use colorSplit(ArrayList<Slice>) and sort(ArrayList<Slice>) to sort
|
||||||
individual lists, then combine into big list similar to scramble method.
|
individual lists, then combine into big list similar to scramble method.
|
||||||
*/
|
*/
|
||||||
ArrayList<Slice> newSlices = new ArrayList<>();
|
|
||||||
ArrayList<Slice> redStuff = new ArrayList<>(privateSort(colorSplit(slices, "red")));
|
ArrayList<Slice> redStuff = new ArrayList<>(privateSort(colorSplit(slices, "red")));
|
||||||
ArrayList<Slice> blueStuff = new ArrayList<>(privateSort(colorSplit(slices, "blue")));
|
ArrayList<Slice> blueStuff = new ArrayList<>(privateSort(colorSplit(slices, "blue")));
|
||||||
ArrayList<Slice> blackStuff = new ArrayList<>(privateSort(colorSplit(slices, "black")));
|
ArrayList<Slice> blackStuff = new ArrayList<>(privateSort(colorSplit(slices, "black")));
|
||||||
|
@ -70,18 +67,17 @@ public class GameWheel
|
||||||
int redCount = 0;
|
int redCount = 0;
|
||||||
for (int i = 0; i < 20; i++){
|
for (int i = 0; i < 20; i++){
|
||||||
if (i % 5 == 0){
|
if (i % 5 == 0){
|
||||||
newSlices.add(blackStuff.get(blackCount));
|
slices.add(blackStuff.get(blackCount));
|
||||||
blackCount++;
|
blackCount++;
|
||||||
} else if (i % 2 == 0){
|
} else if (i % 2 == 0){
|
||||||
newSlices.add(blueStuff.get(blueCount));
|
slices.add(blueStuff.get(blueCount));
|
||||||
blueCount++;
|
blueCount++;
|
||||||
} else {
|
} else {
|
||||||
newSlices.add(redStuff.get(redCount));
|
slices.add(redStuff.get(redCount));
|
||||||
redCount++;
|
redCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
slices.subList(0, 20).clear();
|
slices.subList(0, 20).clear();
|
||||||
slices.addAll(newSlices);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* COMPLETED METHODS - YOU DO NOT NEED TO CHANGE THESE */
|
/* COMPLETED METHODS - YOU DO NOT NEED TO CHANGE THESE */
|
||||||
|
|
Loading…
Reference in a new issue