codecode
Overview The Slot Machine is a popular casino game that comes in a lot of shapes and sizes, but all have the same basic functionality: Multiple wheels are spun simultaneously, and then stop randomly. When all wheels have stopped, the prize value (if any) is based on the number of matching wheel values. You will create three incremental versions of the game called SlotMachine1, SlotMachine2 and SlotMachine3. After you complete SlotMachine1, copy your code into SlotMachine2, then add features to it. You’ll do the same by copying your SlotMachine2 code as your starting point for SlotMachine3. Read the instructions for each program carefully, and make sure the format of your output matches the sample output in the instructions. Pre-Lab (5 Points) Create the shell programs for SlotMachine1.java with the method signatures and comments provided in the instructions. Bring to your lab class for credit. Of course if you work ahead, these can include whatever code you have written so far.Version 1 (30 Points) Create a Java solution for the game SlotMachine1. In this incomplete version of the game, player simply spins until choosing to quit. The spun values will be displayed after each spin, as shown in the sample output on the right à Your solution should have the following two methods: main method Create a loop which does the following: Prompt user whether to Spin or Quit If Q, exit the loop if S, call the spinWheel method three times – Each time spinWheel is called, a String is returned – Save those returned String values in three String variables – Print the three spin values spinWheel method Create a String array containing four Strings of your choice. Generate a random number which represents the index location of one of the 4 Strings in the array. Return that String from the array to the main method.(Sample Output:SlotMachine1>java SlotMachine1Spin/Quit (S/Q) :sWilma – Fred – WilmaSpin/Quit (S/Q) :sWilma – Fred – BarneySpin/Quit (S/Q) :sFred – Barney – FredSpin/Quit (S/Q) :sBetty – Barney – BettySpin/Quit (S/Q) :sFred – Barney – FredSpin/Quit (S/Q) : q)Version 2 (35 Points) Create a Java solution for the game SlotMachine2. Start by copying your working code from SlotMachine1 as the starting point for this version. Revision of SlotMachine1 with the following changes: Add a method called checkWinner which accepts three String values as parameters, and compares them. This method should return a double with the prize amount of the spin. If all three Strings are the same, print “Won $1” and return 1.0 to the main method. If two of the Strings match, print “Won 50 cents” and return 0.5 to the main method. Otherwise, print “No prize” and return 0.0 to the main method. In the main method, after the line that displays the three spun values, add a line that calls the checkWinner method, passing the three String values from calling spinWheel. The number (double) returned by checkWinner will be needed in version 3.(Sample Output:SlotMachine2>java SlotMachine2Spin/Quit (S/Q) : sWilma – Wilma – WilmaWon $1Spin/Quit (S/Q) : sBarney – Barney – BarneyWon $1Spin/Quit (S/Q) : sBetty – Wilma – Fred No prizeSpin/Quit (S/Q) : sFred – Fred – Barney Won 50 centsSpin/Quit (S/Q) : q)Version 3 (30 Points) Create a Java solution for the game SlotMachine3. Start by copying your working code from SlotMachine2 as the starting point for this version. Your solution should have three methods: main, checkWinner, and spinWheel Revision of SlotMachine2 with the following changes: In the main method: Add a double variable to store the player’s money. Prompt the user for how much money to insert when starting the game, and store that value in the money variable. Each time the player chooses to Spin, subtract 25 cents to pay for the spin, then add back any amount the player won using the value returned by the checkWinner method. Add print statements to match the sample output.(Sample Output:SlotMachine3>java SlotMachine3How much money would you like to insert? 100Spin/Quit (S/Q) : sPaid 0.25 to spin….Barney – Betty – BettyWon 50 cents You now have $ 100.25Spin/Quit (S/Q) : sPaid 0.25 to spin….Betty – Wilma – FredNo prizeYou now have $ 100.00Spin/Quit (S/Q) : sPaid 0.25 to spin….Wilma – Betty – BettyWon 50 centsYou now have $ 100.25Spin/Quit (S/Q) : s Paid 0.25 to spin….Wilma – Fred – FredWon 50 centsYou now have $ 100.50Spin/Quit (S/Q) : q