Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Assignment This assignment is about using arrays. You will define two classes - one to represent the wheel of a slot machine, and one

image text in transcribed

image text in transcribed

image text in transcribed

The Assignment This assignment is about using arrays. You will define two classes - one to represent the wheel of a slot machine, and one to represent the slot machine itself (these are the model classes). Then you will spin the wheels of the slot machine and create a histogram of the results. The view class for this assignment uses the FxAnimation template and combines text output with simple graphics. BAR BAR 1-D 25 The Slot Machine (model) A Slot Machine object has a set of Wheel objects in an array. Each Wheel object can be a different color, but each has the same set of faces. The number of Wheel objects, their colors, and the text for each face of a wheel object is determined by parameters passed to a constructor when a Slotmachine object is created. The Slot Machine constructor creates the wheel objects and stores them in an array. A Slotmachine can spin its wheels and can report the current payout. If none of the wheels are showing matching faces, the payout is 0. If at most two of them match, the payout is 1, if at most three match the payout is 2, and so on. It has a histogram method (see below). It also has a toString() method that that reports the number of wheels and faces, the current state of each wheel, and the current payout. Finally, it can also draw the current state of its wheels on a GraphicsContext object. That's all it can do. A Wheel object has a set of faces ("7", "Cherries", "Bar", etc.) in an array. It also has a color that it uses to display itself. The color, the number of faces, and the text of each face on the wheel is set when Wheel object is created and cannot be changed. A wheel can spin itself (i.e. choose a new face). It can also report the number of faces it has, and the index (0 or more) of the current face that is showing. It has a toString() method that reports the text of the current face. It can also draw itself on a GraphicsContext when it is given an x and y location. That's all it can do. The Histogram Method The histogram method of Slotmachine spins the wheels a million times by calling its own spin method. It uses an array of counters to record the number of times each payout comes up (this is a histogram). For example, if the payout is 3, you should add 1 to array element 3. Then it returns the histogram array. See HistogramExample.java in this weeks examples for some code that might help. Design and implementation The exact details of the implementation and interface of these two classes is up to you, but you must respect the specifications given above, and you must create and hand in a UML class diagram to Gaussian Distribution of 206 NE represent wheel, Slotmachine and the association relationship between the two classes. This UML diagram can be hand drawn, or it you can use UMLet or draw.io. If you have another piece of software you would like to use, check with your instructor. The View The view should be implemented using the FxAnimationTemplate. The animate method should start by asking the user to choose from two different slot machines (different number, text, and colors of wheels). Then it should create the Slotmachine requested, print it to the screen, and draw it on the GraphicsContext. Then it should present a menu in a loop that allows them to spin once or a million times. If they choose to spin once, show the result by printing the Slot Machine and by displaying it graphically. If they choose a million spins, call the histogram method described above, and print the result that are returned, as shown in the example output. Extras For a further challenge, you could specify images as well as texts for each wheel. You'll have to change the Wheel constructor to accept an array of images, then use those instead of the text when you display the wheels graphically. You could also add sounds, more realistic monetary payouts, make it look like a real slot machine, etc. Handing In See the due date on Canvas. Hand in a zipped version of your.java (not.class) files and your UML class diagram to the Canvas Assignment. Evaluation Your assignment will be evaluated for performance (20%), class diagram (20%), structure (40%), and documentation (20%) using the rubric in the drop box. Example Output Below is an example output of the program. User input is boldfaced and red. You are free to make your interface look however you like. Choose a machine. Machine 1 is colorful and has 5 wheels with 9 faces. Machine 2 is monochrome and has 7 wheels with 7 faces. 1 Slotmachine! (5 wheels, 9 faces) wheels=[Cherry, Cherry, Cherry, Cherry, Cherry] Payout = 4 Cherry Cher 1=spin. 2=lotsa spins. 3=no more spins. Cherry Cherry 1 Slotmachine! (5 wheels, 9 faces) wheels=[Strawberry, Banana, Kiwi, Apple, Orange) Payout = 0 Strawberry Banana 1-spin. 2=lotsa spins. 3=no more spins. 2 Apple Orange Payout Occurrences 0 255854 1 640048 2 97675 6264 4 159 Grapes Kiyi Slotmachine! (5 wheels, 9 faces) wheels=[Grapes, Kiwi, Bomb, Avocado, Grapes] Payout = 1 1=spin. 2=lotsa spins. 3=no more spins. 3 Avocado Grapes Bye! Process finished with exit code o Optional Extra: Here's a nicer way to display a histogram, courtesy of Mark Yendt. Scale the numbers down and print asterisks to represent the quantities. 5001 9981 7: 14801 9968 9: 20099 10: 9918 11: 15098 12: 10078 13: 5056 or you could use graphics... The Assignment This assignment is about using arrays. You will define two classes - one to represent the wheel of a slot machine, and one to represent the slot machine itself (these are the model classes). Then you will spin the wheels of the slot machine and create a histogram of the results. The view class for this assignment uses the FxAnimation template and combines text output with simple graphics. BAR BAR 1-D 25 The Slot Machine (model) A Slot Machine object has a set of Wheel objects in an array. Each Wheel object can be a different color, but each has the same set of faces. The number of Wheel objects, their colors, and the text for each face of a wheel object is determined by parameters passed to a constructor when a Slotmachine object is created. The Slot Machine constructor creates the wheel objects and stores them in an array. A Slotmachine can spin its wheels and can report the current payout. If none of the wheels are showing matching faces, the payout is 0. If at most two of them match, the payout is 1, if at most three match the payout is 2, and so on. It has a histogram method (see below). It also has a toString() method that that reports the number of wheels and faces, the current state of each wheel, and the current payout. Finally, it can also draw the current state of its wheels on a GraphicsContext object. That's all it can do. A Wheel object has a set of faces ("7", "Cherries", "Bar", etc.) in an array. It also has a color that it uses to display itself. The color, the number of faces, and the text of each face on the wheel is set when Wheel object is created and cannot be changed. A wheel can spin itself (i.e. choose a new face). It can also report the number of faces it has, and the index (0 or more) of the current face that is showing. It has a toString() method that reports the text of the current face. It can also draw itself on a GraphicsContext when it is given an x and y location. That's all it can do. The Histogram Method The histogram method of Slotmachine spins the wheels a million times by calling its own spin method. It uses an array of counters to record the number of times each payout comes up (this is a histogram). For example, if the payout is 3, you should add 1 to array element 3. Then it returns the histogram array. See HistogramExample.java in this weeks examples for some code that might help. Design and implementation The exact details of the implementation and interface of these two classes is up to you, but you must respect the specifications given above, and you must create and hand in a UML class diagram to Gaussian Distribution of 206 NE represent wheel, Slotmachine and the association relationship between the two classes. This UML diagram can be hand drawn, or it you can use UMLet or draw.io. If you have another piece of software you would like to use, check with your instructor. The View The view should be implemented using the FxAnimationTemplate. The animate method should start by asking the user to choose from two different slot machines (different number, text, and colors of wheels). Then it should create the Slotmachine requested, print it to the screen, and draw it on the GraphicsContext. Then it should present a menu in a loop that allows them to spin once or a million times. If they choose to spin once, show the result by printing the Slot Machine and by displaying it graphically. If they choose a million spins, call the histogram method described above, and print the result that are returned, as shown in the example output. Extras For a further challenge, you could specify images as well as texts for each wheel. You'll have to change the Wheel constructor to accept an array of images, then use those instead of the text when you display the wheels graphically. You could also add sounds, more realistic monetary payouts, make it look like a real slot machine, etc. Handing In See the due date on Canvas. Hand in a zipped version of your.java (not.class) files and your UML class diagram to the Canvas Assignment. Evaluation Your assignment will be evaluated for performance (20%), class diagram (20%), structure (40%), and documentation (20%) using the rubric in the drop box. Example Output Below is an example output of the program. User input is boldfaced and red. You are free to make your interface look however you like. Choose a machine. Machine 1 is colorful and has 5 wheels with 9 faces. Machine 2 is monochrome and has 7 wheels with 7 faces. 1 Slotmachine! (5 wheels, 9 faces) wheels=[Cherry, Cherry, Cherry, Cherry, Cherry] Payout = 4 Cherry Cher 1=spin. 2=lotsa spins. 3=no more spins. Cherry Cherry 1 Slotmachine! (5 wheels, 9 faces) wheels=[Strawberry, Banana, Kiwi, Apple, Orange) Payout = 0 Strawberry Banana 1-spin. 2=lotsa spins. 3=no more spins. 2 Apple Orange Payout Occurrences 0 255854 1 640048 2 97675 6264 4 159 Grapes Kiyi Slotmachine! (5 wheels, 9 faces) wheels=[Grapes, Kiwi, Bomb, Avocado, Grapes] Payout = 1 1=spin. 2=lotsa spins. 3=no more spins. 3 Avocado Grapes Bye! Process finished with exit code o Optional Extra: Here's a nicer way to display a histogram, courtesy of Mark Yendt. Scale the numbers down and print asterisks to represent the quantities. 5001 9981 7: 14801 9968 9: 20099 10: 9918 11: 15098 12: 10078 13: 5056 or you could use graphics

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Google Analytics 4 The Data Driven Marketing Revolution

Authors: Galen Poll

2024th Edition

B0CRK92F5F, 979-8873956234

More Books

Students also viewed these Databases questions