Professional Documents
Culture Documents
Project 2
Project 2
Project 2 –
1. Goals
This project aims to implement a rock-paper-scissors game on a web page. You will
solve the problem using only the JavaScript elements studied in lectures and labs.
This project allows you to earn up to 20 extra credit points by adding additional
functionality.
After completing this project, you will gain experience with the following:
1.1. Reminders
Honesty: While you are encouraged to have high-level discussions with your fellow
students, you must be able to complete the details of this project on your own.
Late Policy: All projects are due by 11:59 pm of the posted deadline. Projects
uploaded after the due date/time are considered late and will not be graded.
If both players show the same sign, it is a tie or draw. And that is the whole game! It’s
often played in a best-two-out-of-three format as a quick contest to decide who gets
to go first or something like that.
In your program, the user selects a hand sign, and the computer, not knowing what
you have chosen, randomly selects its hand sign. This action is not simultaneous but is
equivalent to being blindfolded. You can find the images on Canvas->Projects-
>project-2-images.
2. Incremental Development
Incremental development means building part of a program before making it all. It is a
staging strategy in which product features are developed and delivered to users at
different times, increasing its functionality and complexity.
Complete each of the following project stages.
Fig. 1. Behavior of the web page buttons.html after clicking the paper button.
As part of this first partial solution, you must implement the Cascade Style Sheet
required to display the buttons and their images adequately formatted.
All three button HTML elements must execute the function play included in your
JavaScript file. The function play receives the button’s name the user clicked on as an
argument. You will find the three hand-sign images on
Canvas->Files->Projects->project-2->images.
The required files in this part are 111/p2/buttons.html, 111/p2/rps.css, and
111/p2/rps-b.js.
Modify the file buttons.html if needed and save the new version as
computer-plays.html. Extend the style file rps.css as needed. Save all the functions
in the files rps-cp.js.
The required files in this part are 111/p2/computer-plays.html, 111/p2/rps.css, and
111/p2/rps-cp.js.
document.getElementById(elementID).innerHTML = newContent;
where elementID is a string variable that stores the target element id, and
newContent is the variable that stores the new content for that element. Generally,
newContent is a string that represents HTML code.
Modify the file computer-plays.html as needed and save the new version as
rock-paper-scissors.html. Extend the style file rps.css as needed. Save all the
functions in the files rps.js.
The required files in this part are 111/p2/rock-paper-scissors.html, 111/p2/rps.css,
and 111/p2/rps.js.
Fig. 4. Extra credit – the program must keep a score of all the games played and how
many the Human and the Computer have won. A Reset button sets all counters to
zero.
try {
module.exports.calculateDogAge = calculateDogAge;
module.exports.perimeter = perimeter;
module.exports.area = area;
module.exports.C2F = C2F;
module.exports.F2C = F2C;
} catch (err) {
console.log("lab-2.js functions loaded");
}
Do not remove them, or none of your programs will not pass the unit tests.