Instructions For this assignment, you will work on a multi-file program which represents a game using a spinnable Game Wheel, a bit like the one seen on the show Wheel Of Fortune (below). | BRE OOCO 002 OOD OOO OON ason 000) NOO huid 28 OCIO MCZARDAK OOD Your Game Wheel will have 20 evenly cut colored "slices each marked with a cash prize amount. Two classes are used to create this wheel: GameWheel and Slice. You will not need to edit the Slice class, but you will implement some of the methods for the GameWheel class. You will also write a method in a third class named Game which can be used to play the game. As this assignment uses pre-written methods which you will need to use in your code, brief documentation of the constructors and public methods of the GameWheel and Slice classes is included at the end of the assignment brief. Part 1: GameWheel When a new GameWheel is created it always contains 20 slices, which are represented in the GameWheel class by an ArrayList of Slice objects. The wheel is initialized so that every slice with an odd index is red and every slice with an even index is blue, with the exception of the slices at positions 0,5.10 and 15 which are all black. Every slice is initialized with a different prize value. You will implement three different public methods in the GameWheel class. toString The first of these methods is the toString method, which returns a String consisting of a numbered list of all slices of GameWheel (using the slice toString method), one on each line. This should be in the format shown below: 0 - Color: black, Prize Amount: $4000 1 - Color: red, Prize Amount: $10 2 - Color: blue, Prize Amount: $200 3 - Color: red, Prize Amount: $30 19 - Color: red, Prize Amount: $190 You may find the toString method helpful when testing your other GameWheel methods. scramble The second method you will write is the scramble method, which randomizes the positions of the slices that are in the wheel, but without changing the pattern of the colors (l.e. the black slices will still be at multiples of 5, the red slices at all other odd indices and the blue slices at all other even indices). No individual slice should be changed, rather the slices should be re-ordered The third method to implement is the sort method. This is similar to the scramble method in that it reorders the slices in the GameWheel so that the pattern of the colors remains the same. After the sort method is called however the slices of each color should be sorted in increasing order of prize amount. So for example the black slice with the lowest prize value will be at index 0, and the black slice with the highest prize value will be at index 15 Part 2: Game/play When you have done the above, you will write a method in the Game class named play. This method has a single GameWheel parameter. When run, this method will simulate a game in which the game wheel represented by this parameter is spun three times and the results are used to calculate a total prize. The total prize is found by adding the values on the three slices. If all three stices are the same color, then this sum should be doubled (and an additional line should be printed at the end explaining this). For the exact format of the output of the program, see the sample runs below (as this program involves some randomization the actual output will vary). Sample run 1 Total prize money: $7000 Spin 1- Color: black, Prize Amount: 54000 Spin 2 - Color: blue, Prize Amount: $2400 Spin 3 - Color: blue, Prize Antount: $600 Sample run 2 Total prize noney: 5820 Spin 1 - Color: red, Prize Amount: $50 Spin 2 - Color: red, Prize Amount: $130 Spin 3 - Color: red, Prize Amount: $230 Three reds - double your money! Testing your code The fourth class named Runner has a pre-written main method which will let you test your code. You can choose to play the game by calling the play method from your game class or test individual methods from the GameWheel class. Please do not write a main method in any of the other classes as these will stop your code from being scored correctly. Documentation Slice class Slice(String c, int p) Creates a slice with color c, and cash prize p. int getPrizeAmount() Returns the cash prize in dollars for this slice String getColoro Returns the color of this slice as a string. String toString() Returns a string representation of the slice in the following format: "Color: red, Prize amount: $50". GameWheel class GameWheel) Creates a wheel with 20 slices with preset prize amounts. GameWheelinti Creates a wheel with the prize amounts given in the prizes array, prizes) Slice spinWheelo spins the wheel so that a different slice is selected. Return that slice (Note: the 10 slices following the current slice are more likely to be returned than the other 10). Milestones As you work on this assignment, you can use the milestones below to inform your development process: Milestone 1: Set up the toString method for the gameWheel class so you can test your methods as you write them. Plan how you will decompose the scramble and sort methods (ie are there helper methods which can be used by both). Milestone 2: Write the scramble and sort methods in the gameWheel class. Use the runner class and the toString methods to test these methods work exactly as intended. Milestone 3: Implement the play method in the game class. Make sure you run this multiple times to ensure it works under a variety of conditions. Decomposition hints More than any exercise or assignment you've seen so far, this assignment requires you to carefully decompose what needs to be done into steps. This is especially true when implementing the scramble and sort methods. There is no one right way to do this, and very different approaches can still end up working. Below are some hints which might help you get started, but do feel free to experiment and come up with your own way One way to implement the scramble and sort methods might be to split the sites list up into separate lists by color, then put them back together into the slices list once they are scrambled/sorted. You could sort/scramble these separate lists, or be even smarter and sort/scramble them either as you put them into the list or as you put them back into stices Because there is a lot of repetition in these methods you should think about writing helper methods that prevent you from having to write code which is almost the same several times. Examples of where helper methods could be useful include splitting slices into lists by color, sorting a list, scrambling a list, and recombining separate lists to make a new slices list. Files STATUS NOT SUBMITTED SAVE SUBMIT Game.java GameWheel.java 1 - import java.util.ArrayList; 2 public class Game 4- { 5 public static void playGameWheel g) { FI/ Implement the play method here } 9} 10 runner_GameWheel.java 6 - 7 Slice.java Files O NOT SUITE Game Ganwhile capie auters ulit wie scroll 29 20 21 22. 2 24 29 28 wiec > 34 *COLETES VESTES 38 ulic Con thcart Standard: 2 41 42 44 46 Garies) currento Siroyli For faris.lenge par 57 - co slio Slical, licet in the create be than the no Stick to Inter Chrono Interpos (currentes y sis.2004 Curres mature slices. pet.Currenthe 3 24 75. 76 n 24 78 Inst if(a = || 18) SEL Putu St. 22 Wory with Standard Ima203 (-) are 1000 se if (21) an 13 - 2007 Files Games Game Wheeljava runner GameWhetljava Sliceava NOT SUBMITTED 1 - import java.util.Scanner: 2 3 - public class runner Gothell 4 5 private static Scanner scan; 6 private static String instruct 7 private static Goneheel wheel 8 9. public static void main(String[] args) 10 scon- new Scanner(System.in); wheel - new Gomethelo: 12 instruct 13- while instruct.equals() 14 System.out.println(Type **** to play se, ev to test Czesheel sethods, "4 to quit."); 15 instruct - scan.nextLine: 16 if(instruct.equals("")) 17 Gane.play wheel): 18 else if instruct.equals("t>> 19 testMethods(); 20 else if(!instruct.equals("")) 21 System.out.print("Instruction not recognized 22 System.out.printlno: 23 } 24 } 25 26 private static void testMethods 27 - while instruct equals("") instruct cous 28 System.out.printint Type Ganesher sethod to call (testrins, scramble, sort). Or type 1 for nain mers, 141 to quit"); 29 Instruct = scon.nextLine: 30 if(instruct.equals("toStrine 31 System.out.println(wheel): 32 else if(instruct.equals("scramble')) 33 wheel scramble: 34 else l'instruct.equals(sort) 35 wheel sort: 36 else 1(instruct.equals(new) 37 wheel - new Gonckheel(mokeStarterArroyo): 38 else 1(instruct.equals randon prize.test) 39 40 else if instruct equals() instruct.couts System.out.println("Instruction not recogid: 42 43 } 44 45- private static int makeStarterArray 46 intarr - new int[20: 47 - for(int 1-2; 1 57 wheel scramble: 58 for(int 1-0: 128--> 59 System.out.print(wheel, getSlice(1).getPrizemouto 60 Systes.out.printlno: 61 1 62 scan.nextLine: 63 1 64) 65 Files STATUS NOT SUBMITTED Game.java 1 public class Slice 2-{ 3 private String color; private int prize Amount; GameWheel.java OWN runner_GameWheel.java Slice.java // Creates a slice with color c, and cash prize p public Slice(String c, int p) { color-c; prizeAmount - P: } 6 7 8- 9 10 11 12 13 14 15 16 17 18 19 20 // Returns the cash prize in dollars for this slice public int getPrizeAmount() { return prizeAmount; } 21 - // Returns the color of this slice as a string public String getColor { return color; } 22 23 24 25 26 - 27 28 29- 30 31 32 } 33 */ /* Returns a string representation of the slice in the following format: "Color: red, prize amount: $59". public String toString() { return "Color: " + color +", Prize Amount: $" + prizeAmount; }