Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JSP project help!! For this project you will implement a webpage that allows the user to play the game Rock-Paper-Scissors against the computer. The computer's

JSP project help!!

For this project you will implement a webpage that allows the user to play the game Rock-Paper-Scissors against the computer. The computer's moves are chosen randomly. To practice JavaScript, focusing on functions and "event driven" programming. To review HTML and CSS. The rules are simple: If both players show the same gesture, then it is a tie. Otherwise: Rock beats Scissors Paper beats Rock Scissors beats Paper Hints: The whole thing can be rendered as just a single table. The table will have 5 rows and 3 columns. You will need to make heavy use of rowspan and colspan. For example, the entry at the top that says "Rock Paper Scissors" spans all three columns. Another example: The boxes that show the players' hands -- each of these spans 3 rows. Be sure to use identifiers for elements that will change while the program is running. You will need to use the onClick attribute for the three elements that the user will click on. I suggest having all three of these call the same function. This works well if you use a parameter that represents whichever gesture has been selected. For example, I wrote a function called playGame that has a parameter. When the user clicks the rock icon, I call it this way: playGame("rock"). When the user clicks the paper icon, I call it this way: playGame("paper"). Same idea for scissors. Your javascript should probably use 5 variables because there are 5 things that change while the program is running. Here are the ones I used and their starting values: wins = 0; losses = 0; ties = 0; picForLeftPlayer = "leftPaperHand.jpg"; picForRightPlayer = "rightRockHand.jpg"; To determine a random move for the opponent, you can call the random number generator like this: value = Math.random();. Recall that the value will be a number between 0 and 1. If the value is smaller than 0.3333, use rock. If it is between 0.3333 and 0.6666 use paper, and if it is larger than 0.6666 go with scissors.

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

PostgreSQL Up And Running A Practical Guide To The Advanced Open Source Database

Authors: Regina Obe, Leo Hsu

3rd Edition

1491963417, 978-1491963418

More Books

Students also viewed these Databases questions