Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A. Create a JavaScript program that will have a main class that will store information about the lucky number game and contains the playGame() function.

A. Create a JavaScript program that will have a main class that will store information about the lucky number game and contains the playGame() function.

B. When a player pushes an HTML button, it will call back to a global function (Not the main class), which will then invoke the playGame function from the instance of the main class a. NOTE: this is necessary due to a limitation with JavaScript.

C. Inside the playGame() function - get a random number between 1 and 100, get a second random number between 1 and 100, if the 2nd number is higher print "You Win", otherwise print you lose. (Also print the numbers). a. (NOTE: When I say print I mean to write to the innerHTML of a section in the website). b. You will keep track of how often you have one or lost. (Keep in mind you will NOT have to refresh) c. The won and lost counters can be class variables.

D. If you have won more than lost display a picture of a happy face (using JavaScript to change the src inside of an img tag) a. Otherwise, display an unhappy face. (If you want a special face for win == lose you may add it.) HINTS: First create a class diagram for this assignment - What variables do we need for the class, and what functions do we need? Then implement the game.

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

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

More Books

Students also viewed these Databases questions