Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Please write this in JavaScript code. Make an class called Dice. Dice will have a number of sides Dice will have the number last_rolled Dice

Please write this in JavaScript code.
  • Make an class called Dice.
  • Dice will have a number of sides
  • Dice will have the number last_rolled
  • Dice will have a function call Roll
  • Roll will find a random number between [1 and number of sides]
  • It will set the last_rolled to that number
  • It will also return that number.
  • Make two instances of the dice object (with 20 sides)
  • Continuously roll the two dice until the two dice can be add, subtracted, divided or multiplied to make 10.
  • Print the two dice values and print you win
Requirements:
Create a function, called spin, in the head section that takes no parameters but returns a random number between 0 and 6 inclusive.
Call this function three times and assign it to different variables.
Create another function, called evaluateGame, that takes three parameters and returns the a integer. (ALL WINS are evaluated from left to right 4,0,0 would be a losing game)
1. If there are three 0s for the random values win 14
2. If there are three of any other number win 7
3. If there are two 0s in the first and second spot then win 4.
4. If there are two of any other number in the first two spots win 2.
5. If there are is a 0 in the first spot then win 1.
6. The function will return the win score.
Create a function that takes in a single number. Based on that number you get to print a picture. (0 is cherry, the rest do not matter). (This is an HTML Image tab not canvas)
Underneath the three pictures print the winning score.
Put the above requirements in either a for loop or a while loop and do it three times. (Therefore, you should have three slot machines.)
Put a hyperlink at the bottom that links to the same page, make the text say spin. (You will re-load the page)

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_2

Step: 3

blur-text-image_3

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

Demystifying Databases A Hands On Guide For Database Management

Authors: Shiva Sukula

1st Edition

8170005345, 978-8170005346

More Books

Students explore these related Databases questions

Question

Write formal and informal proposals.

Answered: 3 weeks ago

Question

Describe the components of a formal report.

Answered: 3 weeks ago

Question

Write formal and informal reports.

Answered: 3 weeks ago