diff --git a/out/production/Assignment7/com/company/Game.class b/out/production/Assignment7/com/company/Game.class index 4aa9dee..6208990 100644 Binary files a/out/production/Assignment7/com/company/Game.class and b/out/production/Assignment7/com/company/Game.class differ diff --git a/out/production/Assignment7/com/company/GameWheel.class b/out/production/Assignment7/com/company/GameWheel.class index 3b2cd13..423273b 100644 Binary files a/out/production/Assignment7/com/company/GameWheel.class and b/out/production/Assignment7/com/company/GameWheel.class differ diff --git a/out/production/Assignment7/com/company/Slice.class b/out/production/Assignment7/com/company/Slice.class index 9d82efb..aeba2b7 100644 Binary files a/out/production/Assignment7/com/company/Slice.class and b/out/production/Assignment7/com/company/Slice.class differ diff --git a/src/com/company/Game.java b/src/com/company/Game.java index aa68a11..cdd8df3 100644 --- a/src/com/company/Game.java +++ b/src/com/company/Game.java @@ -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 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"); + } } } diff --git a/src/com/company/GameWheel.java b/src/com/company/GameWheel.java index 7f5ce60..089b0ca 100644 --- a/src/com/company/GameWheel.java +++ b/src/com/company/GameWheel.java @@ -61,6 +61,27 @@ 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<>(sort(colorSplit(slices, "red"))); + ArrayList blueStuff = new ArrayList<>(sort(colorSplit(slices, "blue"))); + ArrayList 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 */