Question
A. Create a full JavaScript program that will have a main class that will store information about the lucky number game and contains the playGame()
A. Create a full 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
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