Chat with us, powered by LiveChat Codecode | Writedemy

Codecode

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 SlotMachine1

Spin/Quit (S/Q) :s

Wilma – Fred – Wilma

Spin/Quit (S/Q) :s

Wilma – Fred – Barney

Spin/Quit (S/Q) :s

Fred – Barney – Fred

Spin/Quit (S/Q) :s

Betty – Barney – Betty

Spin/Quit (S/Q) :s

Fred – Barney – Fred

Spin/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 SlotMachine2

Spin/Quit (S/Q) : s

Wilma – Wilma – Wilma

Won $1

Spin/Quit (S/Q) : s

Barney – Barney – Barney

Won $1

Spin/Quit (S/Q) : s

Betty – Wilma – Fred No prize

Spin/Quit (S/Q) : s

Fred – Fred – Barney Won 50 cents

Spin/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 SlotMachine3

How much money would you like to insert? 100

Spin/Quit (S/Q) : s

Paid 0.25 to spin….

Barney – Betty – Betty

Won 50 cents You now have $ 100.25

Spin/Quit (S/Q) : s

Paid 0.25 to spin….

Betty – Wilma – Fred

No prize

You now have $ 100.00

Spin/Quit (S/Q) : s

Paid 0.25 to spin….

Wilma – Betty – Betty

Won 50 cents

You now have $ 100.25

Spin/Quit (S/Q) : s Paid 0.25 to spin….

Wilma – Fred – Fred

Won 50 cents

You now have $ 100.50

Spin/Quit (S/Q) : q

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Writedemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order