Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create an HTML file that will play a slot machine game with the given instructions. The images are not required, but returning a number in
Create an HTML file that will play a slot machine game with the given instructions. The images are not required, but returning a number in their place is expected.
- This file will have two different classes
- Main
- Slot Machine
- Main class
- The Main class will have the following class variables
- Money (Initially set to 100)
- An array of slot machine instances
- The main constructor will dynamically add a section tag to the document
- This will be used to print the output
- The main constructor will also initialize the slot machine array with 1 instance of the slot machine.
- The main class will also have a function called PlayAll
- If the play button is pressed, then subtract 1 from the current value of Money (make sure it is above 0) and then iterate through the slot machine array and call their respective play function.
- It will then poll all the slot machines and sum the last amount won.
- If is > than 0 then have the word winner and the summed amount won displayed in the section that the main class created
- Else display Game Over
- Add any winnings to the total money.
- The Main class will have the following class variables
- Slot Machine Class
- This class will have the following class variables
- The last amount won
- A list of three numbers
- A list of three HTML image objects.
- Constructor
- The slot machine constructor will dynamically add three HTML images to the document and then store them to the image list.
- Each Image will be 64X64 pixels).
- The last amount won will be initialized to 0.
- Play
- When play is called the slot machine will pick three numbers and populate the number list. The slot machine will randomly choose between 0 and 6 inclusive.
- Make sure you have seven images. Each image will correspond to a certain number between 0 and 6.
- Change the HTML image src parameter to the correct image for the appropriate number. For example, if the number list contains [5,5,4]. The first two images will be the same (that correspond to 5). The third image will have the src set to the appropriate image for 4.
- Slot machine awards are evaluated left to right. Therefore, ORDER DOES Matter.
- Also, you can ONLY win the top award in a slot machine. For example if you get three 0s you do NOT get the two 0s or one 0s award.
- The play function will set the last amount won according to the following table:
- This class will have the following class variables
- After the script that initializes main is run create an HTML button that will call back to a global function which will call the main instance PlayAll
- This button should be labeled play
- Phase 2
- Alter the constructor in Main so you make 3 slot machine instances instead of just 1
- If you coded the main class correctly you should not have to change anything in it.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started