Fixed Game.java sameColor multiplier, tested in Java 8, works.

Cleaned up GameWheel sort and scramble code a bit.
This commit is contained in:
blzimme000 2022-02-22 11:13:54 -06:00
parent fa8208a4f8
commit e400aaed8b

View file

@ -28,7 +28,6 @@ public class GameWheel
public void scramble()
{
//Implement the scramble method here
ArrayList<Slice> newSlices = new ArrayList<>();
ArrayList<Slice> redStuff = new ArrayList<>(shuffle(colorSplit(slices, "red")));
ArrayList<Slice> blueStuff = new ArrayList<>(shuffle(colorSplit(slices, "blue")));
ArrayList<Slice> blackStuff = new ArrayList<>(shuffle(colorSplit(slices, "black")));
@ -37,18 +36,17 @@ public class GameWheel
int redCount = 0;
for (int i = 0; i < 20; i++){
if (i % 5 == 0){
newSlices.add(blackStuff.get(blackCount));
slices.add(blackStuff.get(blackCount));
blackCount++;
} else if (i % 2 == 0){
newSlices.add(blueStuff.get(blueCount));
slices.add(blueStuff.get(blueCount));
blueCount++;
} else {
newSlices.add(redStuff.get(redCount));
slices.add(redStuff.get(redCount));
redCount++;
}
}
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
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> blueStuff = new ArrayList<>(privateSort(colorSplit(slices, "blue")));
ArrayList<Slice> blackStuff = new ArrayList<>(privateSort(colorSplit(slices, "black")));
@ -70,18 +67,17 @@ public class GameWheel
int redCount = 0;
for (int i = 0; i < 20; i++){
if (i % 5 == 0){
newSlices.add(blackStuff.get(blackCount));
slices.add(blackStuff.get(blackCount));
blackCount++;
} else if (i % 2 == 0){
newSlices.add(blueStuff.get(blueCount));
slices.add(blueStuff.get(blueCount));
blueCount++;
} else {
newSlices.add(redStuff.get(redCount));
slices.add(redStuff.get(redCount));
redCount++;
}
}
slices.subList(0, 20).clear();
slices.addAll(newSlices);
}
/* COMPLETED METHODS - YOU DO NOT NEED TO CHANGE THESE */