Can you beat the computer at "Rock, Paper, Scissors"? You'll find out because in this assignment, you will create a web page that allows a person to play this game against the computer. The person should be able to play as many times as he/she wants and your web page should count and display a running total of ties, computer wins and player wins. The page layout will be similar to the picture below. It should have an internal style sheet, a heading, and an image.
The bulk of the page is a form with these elements:
Use a two-column table to organize the form elements. The labels should be in one column and the form elements in the other. Notice how the "Click to Play" and "Start Over" buttons span both columns and take up the entire width of the table. Yours should too.
Here are the rules of the game in case you need a refresher:
Thus, the player is expected to press one of the choice buttons, press the "Click to Play" button, press another choice button, press "Click to Play", and repeat this process as long as she likes. The rest of the fields will show the winner of the current round and a running total of wins. The picture below shows the state of the game after many rounds of play.
There's a lot to do for this assignment, so start early. Take it in steps. Place all of your Javascript functions inside your HTML file. And remember your two best friends when it comes to Javascript: the error console in Firefox and alert boxes that you can use at any point in your code to display the contents of a variable. Here's the approach I recommend.
choice = Math.random();
After the above line executes, a random number will be assigned to the variable "choice". If the number in "choice" is less than 1/3, this means the computer chose rock; if it's between 1/3 and 2/3, the computer chose paper; otherwise the computer chose scissors. Depending on what was chosen, place the appropriate text into the text field for the computer's choice. Call this function when the user clicks the "Click to Play" button. Debug until it works.
Name this page "index.html" and publish it to your "hw7" folder. Don't forget to update your Assignments Directory from Assignment 4 with a new link. Test on IE and Firefox. And, as always, don't forget your DTD, comments, and meta tags for both keywords and a description.
Please turn in printouts of all XHTML, CSS, and JS code.
All assignments are individual projects. I encourage you to talk to others about the general nature of the project and ideas about how to pursue it. However, the technical work, the writing, and the inspiration behind these must be substantially your own. If any person besides you contributes in any way to the project, you must credit their work on your assignment. Similarly, if you include information that you have gleaned from other published sources, you must cite them as references. Looking at, and/or copying, other people's written work is inappropriate, and will be considered cheating.