Answered step by step
Verified Expert Solution
Link Copied!

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.

  1. This file will have two different classes
    1. Main
    2. Slot Machine
  2. Main class
    1. The Main class will have the following class variables
      1. Money (Initially set to 100)
      2. An array of slot machine instances
    2. The main constructor will dynamically add a section tag to the document
      1. This will be used to print the output
    3. The main constructor will also initialize the slot machine array with 1 instance of the slot machine.
    4. The main class will also have a function called PlayAll
    5. 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.
    6. It will then poll all the slot machines and sum the last amount won.
      1. If is > than 0 then have the word winner and the summed amount won displayed in the section that the main class created
      2. Else display Game Over
    7. Add any winnings to the total money.
  3. Slot Machine Class
    1. This class will have the following class variables
      1. The last amount won
      2. A list of three numbers
      3. A list of three HTML image objects.
    2. Constructor
      1. The slot machine constructor will dynamically add three HTML images to the document and then store them to the image list.
      2. Each Image will be 64X64 pixels).
      3. The last amount won will be initialized to 0.
    3. Play
      1. 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.
      2. Make sure you have seven images. Each image will correspond to a certain number between 0 and 6.
      3. 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.
      4. Slot machine awards are evaluated left to right. Therefore, ORDER DOES Matter.
      5. 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.
      6. The play function will set the last amount won according to the following table:
  4. 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
    1. This button should be labeled play
  5. Phase 2
    1. Alter the constructor in Main so you make 3 slot machine instances instead of just 1
    2. 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

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions