From e400aaed8bfa8ccc389abe9be70492552cc68137 Mon Sep 17 00:00:00 2001 From: blzimme000 Date: Tue, 22 Feb 2022 11:13:54 -0600 Subject: [PATCH] Fixed Game.java sameColor multiplier, tested in Java 8, works. Cleaned up GameWheel sort and scramble code a bit. --- src/com/company/GameWheel.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/com/company/GameWheel.java b/src/com/company/GameWheel.java index 623d675..3f24d0b 100644 --- a/src/com/company/GameWheel.java +++ b/src/com/company/GameWheel.java @@ -10,7 +10,7 @@ public class GameWheel /* Returns string representation of GameWheel with each numbered slice - * on a new line + * on a new line */ public String toString(){ //Implement the toString method here @@ -28,7 +28,6 @@ public class GameWheel public void scramble() { //Implement the scramble method here - ArrayList newSlices = new ArrayList<>(); ArrayList redStuff = new ArrayList<>(shuffle(colorSplit(slices, "red"))); ArrayList blueStuff = new ArrayList<>(shuffle(colorSplit(slices, "blue"))); ArrayList 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) and sort(ArrayList) to sort individual lists, then combine into big list similar to scramble method. */ - ArrayList newSlices = new ArrayList<>(); ArrayList redStuff = new ArrayList<>(privateSort(colorSplit(slices, "red"))); ArrayList blueStuff = new ArrayList<>(privateSort(colorSplit(slices, "blue"))); ArrayList 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 */