Sort and Scramble done, Game.java done (I think)

This commit is contained in:
blzimme000 2022-02-18 11:07:42 -06:00
parent 6ae8461d8a
commit cac5182b6a
5 changed files with 42 additions and 3 deletions

View file

@ -1,10 +1,28 @@
package com.company;
import java.util.ArrayList;
public class Game
{
public static void play(GameWheel g)
{
public static void play(GameWheel g){
// Implement the play method here
String slice1 = GameWheel.spinWheel().toString();
ArrayList<Slice> slices = new ArrayList<>();
for (int i = 0; i < 3; i++){
slices.add(g.spinWheel());
}
boolean sameColor = false;
if (slices.get(0).getColor().equals(slices.get(1).getColor()) && (slices.get(0).getColor().equals(slices.get(2).getColor()))){
sameColor = true;
System.out.println("Total prize money: $" + (2*slices.get(0).getPrizeAmount() + slices.get(1).getPrizeAmount() + slices.get(2).getPrizeAmount()) + "\n");
} else {
System.out.println("Total prize money: $" + (slices.get(0).getPrizeAmount() + slices.get(1).getPrizeAmount() + slices.get(2).getPrizeAmount()) + "\n");
}
for (Slice e : slices){
System.out.println(e);
}
if (sameColor){
System.out.println("Three " + slices.get(0).getColor() + "s = double your money");
}
}
}

View file

@ -61,6 +61,27 @@ 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<>(sort(colorSplit(slices, "red")));
ArrayList<Slice> blueStuff = new ArrayList<>(sort(colorSplit(slices, "blue")));
ArrayList<Slice> blackStuff = new ArrayList<>(sort(colorSplit(slices, "black")));
int blackCount = 0;
int blueCount = 0;
int redCount = 0;
for (int i = 0; i < 20; i++){
if (i % 5 == 0){
newSlices.add(blackStuff.get(blackCount));
blackCount++;
} else if (i % 2 == 0){
newSlices.add(blueStuff.get(blueCount));
blueCount++;
} else {
newSlices.add(redStuff.get(redCount));
redCount++;
}
}
slices.subList(0, 20).clear();
slices.addAll(newSlices);
}
/* COMPLETED METHODS - YOU DO NOT NEED TO CHANGE THESE */