Create web page that plays the rock, paper-scissors game

Assignment Help Computer Engineering
Reference no: EM131305445

Purpose:

This project involves creation of a web page that plays the Rock, Paper, Scissors game with the user.

Basic Features:
Your web version of the game needs to have the following required features:
A proper title.
Buttons or a "select" list for the user to choose rock, paper, or scissors.
A "shoot" button.
• Display of each of the following:
What the user picked.
What the computer picked.
Who won
Total score for the user.
Total score for the computer.
15 points for proper interaction of the components listed above and good overall coding style.

The computer should choose randomly from the 3 choices of rock, paper, or scissors randomly and not cheat by using the user's selection to make the winning choice! Recall that we used the Math.random () function to get random numbers. You can use that to select a random choice for this game.

Planning Your Solution:

Build up your solution in steps:

- First, sketch out the collection of input and output text boxes you need, the buttons you need, etc. Then implement them in HTML. At this point, don't worry about any event handlers. Also, don't make the page super-fancy and colorful. That can come later.
- Then for each event handler you need (one each for the 4 buttons or list elements), write a function that does nothing more than show an alert saying which button was clicked.
- Next, think about what sort of information you need in order to run the game. There are several variables you will need to keep track of what is going on:
• User's pick
• Computer's pick
• Winner

• Total wins for Computer (initially 0)
• Total wins for User (initially 0)

Use var declarations inside the script tag to define these.

Now it is time to think about your strategy for keeping track of the user's selection of rock, paper, or scissors, and to make the computer's selection. You have created a variable to hold the user's choice.

Each of the three selection buttons (rock, paper, and scissors) sets that variable. You'll have to decide what values to use for this variable. You might use numbers (for example, rock is 0, paper 1, and scissors 2), or strings (perhaps 'rock', 'paper, and 'scissors', or maybe just 'R', 'P', and 'S'). Modify the functions you wrote for each of the buttons for rock, paper, and scissors to set this variable.

The function that implements the event handler for the 'shoot' button has more work to do. First you need to make a random choice for the computer of rock, paper, or scissors. Do this by choosing a random number 0, 1, or 2 (recall the example in class that did something like this). If you used numbers to represent rock, paper, and scissors, you are done, otherwise you need a series of if statements to assign the appropriate string. In any case, you store the computer choice in a variable.

Temporarily, put an alert here showing the user's choice and the computer's choice. That will let you see that you have the values in your variables that you think are there. Now, continuing with the 'shoot' event handler, you need to compare the computer's choice with the user's choice. Create a variable to identify the result (computer wins, user wins, and tie). You'll need a series of if statements to do this.

With the winner determined, update the total wins for the computer or the user (or neither, in the case of a tie). Temporarily, put an alert here to show the values of these variables.

Finally, display your output to the user by updating the values in the boxes for winner, computer score, and user score. (If you want also to show the number of ties, go ahead!)
When everything works, remove the alerts that were put in temporarily.

A Word about Coding Style:

Good style not only helps us read your code. It helps you figure out what you had in mind when you come back to your code after being away from it. Use variable names that suggest their purpose. Words do better in this regard than abbreviations (for example winComputer versus wc). The same concept applies to function names and to the IDs for elements of your HTML web page. Use good indentation so that it is easy to see what code in part of a loop, function, etc. The same indentation ideas apply to your HTML code.

Avoid repeated code. If you are writing basically the same code a second time with only minor changes, writing a single function that can be called from both places may be a better approach.

Added Features:

These features don't add functionality but make the page look better. Add them once the basic features Work:

Neat placement of items on the page (alignment, centering, etc.).
Use of color.
A reset button to set the scores back to zero.
Graphical images of rock, paper, and scissors

Extra Items beyond the Requirements:
Feel free to add more features beyond the "basic" and "added" ones.

Submit File:
When you have finished, submit your html file to Course Site as normal using a single zip file. Use a zip file even if you have only one file to submit. If you have embedded images, you'll have more than one file and you will to include them in your zip file.

Grading and Honor Code:

The basic features are 80 percent and the added features 20 percent. For each feature approximately 1/3 is for the html and 2/3 for the JavaScript. Note that because some code impacts multiple features, it may not always be possible to divide points exactly according to the scale given above. In particular, significant amounts of repeated code will result in points lost even though everything may work correctly.

We expect this to be your own work. You may get help from the course instructor or graders. If you have a tutor, be sure NOT to use code written by the tutor. University tutors often give the same suggestions to multiple students resulting in multiple students having the same solution. Such cases look like cheating and will be treated as such. There are RPS programs on the web. Don't try to copy those (we can find them too!). Even just "reading" such code to "learn" is dangerous as this often results in code that is very similar to those posted solutions. If we have reason to question the amount of help you have received, we reserve the right to call you in to explain the working of your code.

Reference no: EM131305445

Questions Cloud

Write introduction and motivation about iclusig : Write Introduction and Motivation (1 or 2 pages), perhaps including some figures of the project and I have attached everything related to the project. Acute Lymphoblastic Leukemia (ALL) is a type of cancer of the blood and bone marrow that affects ..
Explain communication patterns-important cultural : Explain communication patterns, important cultural and religious rituals, customs, and beliefs, and how to avoid cultural barriers (i.e. what would constitute good manners and respect and what would cause offense in this ethnic group). Please ela..
Current price and yield on 30 year us treasury security : What are the current price and yield on a 10-year U.S. Treasury security? What are the current price and yield on a 30-year U.S. Treasury security?
Show that the bilinear transformation of a pd controller : Show that the bilinear transformation of a PD controller with a high-frequency pole that makes the controller transfer function proper does not yield a pole at z = -1.
Create web page that plays the rock, paper-scissors game : CSE 001 - Fall 2016 - Creation of a web page that plays the Rock, Paper, Scissors game with the user - The computer should choose randomly from the 3 choices of rock, paper, or scissors randomly and not cheat by using the user's selection to make t..
What are the determinants of asset demand : What is a portfolio?- What are the determinants of asset demand?- How do economists define expected return and risk?
Difference between market risk and idiosyncratic risk : What is the difference between market risk and idiosyncratic risk?- What is diversification? How does it reduce the risk of a financial portfolio?
Impac of tmoving from a budget deficit to a budget surplus : Use a demand and supply graph to illustrate the impact that moving from a budget deficit to a budget surplus would have on the bond market, holding everything else constant.
How important is trust to a cross-functional team : How important is trust to a cross-functional team? Describe how managers can build trust among cross-functional teams, which comprise diverse backgrounds and differing perspectives.Explain which type of cohesiveness, socio-emotional or instrumenta..

Reviews

Write a Review

Computer Engineering Questions & Answers

  Transcripting the case

The CTO of organization that has requested your services would like for your forensics team prepare a transcript of what you could state to CTO.

  Write a compiler program that allows variables

Write a compiler program that allows variables in the postfix expressions; for each variable, the program should ask the user for the value of this variable, and then compute the value of the corresponding expression.

  Developing a pseudocode and the flowchart

Develop a flowchart or puesdocode that carry out the following task:. a) Begin the program. b) Declares the strings. c) Accept an input studentname.

  What are the ethics of setting up an rfid tag scanner

What are the ethics of setting up an RFID tag scanner in the classroom door? disxuss this form the act utilitraianism viewpint and mechanics of what data it could reveal.

  The importance of the common protocol (tcp/ip)

how the other future communication needs may or may not continue this dependence.

  Design the algorithm used to implement the given game

Design of the algorithm used to implement the game. Design of the program. The design involves a description of the way that you organised the information and the design of the program.

  Implement a code in lisp to construct lists of random number

Implement a code in LISP to construct lists of random numbers, and lists of consecutive numbers. Show that length is correct for longer lists using the built in function length. Show that the average value of random list entries is as expected.

  Perform the tasks below by using the correct sql statements

perform the tasks below by using the correct sql statements. you must create the statements in oracle by using the

  Write a short memo explaining the concept to your boss

Using the Web, investigate the term, virtual desktop infrastructure (VDI). Write a short memo explaining the concept to your boss.

  Write a program that imitates a lottery

Write a program that imitates a lottery. The program will use two one-dimensional arrays to store the winning numbers and the user's choices. A function will be use to decide whether the user has won or not.

  How is moores law relevant to programmers

Suppose a transistor on an integrated circuit chip were 2 microns in size. According to Moore's Law, how large would that transistor be in 2 years? How is Moore's law relevant to programmers?

  Describe at least three items that an organizations it is

write a two to three page paper in which youdescribe at least three items that an organizations it is department

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd