CIT020 Index > Assignment 9

Assignment 9 - Rock/Scissors/Paper

Read everything before doing anything.

The object of this program is to make the computer play Rock/Scissors/Paper. Here is what a sample run of this program might look like:

Welcome to Rock/Scissors/Paper
How to play:
You choose R for rock, S for scissors, or P for paper.
The computer will also make a choice.
Scissors cuts paper (so scissors wins).
Paper wraps rock (so paper wins).
Rock breaks scissors (so rock wins).
If your choice matches the computer's, nobody wins.

Your choice: R)ock, S)cissors, P)aper, or Q)uit: x
Please enter R for rock, S for scissors, P for paper, or Q to quit: s
Computer chose Paper - you win.

Your choice: R)ock, S)cissors, P)aper, or Q)uit: p
Computer chose Scissors - you lose.

Your choice: R)ock, S)cissors, P)aper, or Q)uit: R
Computer chose Rock - it's a draw.

Your choice: R)ock, S)cissors, P)aper, or Q)uit: R
Computer chose Scissors - you win.

Your choice: R)ock, S)cissors, P)aper, or Q)uit: Q

Your wins: 2
Computer's wins: 1
Number of draws: 1

You may see the pseudocode for the program; this is what we designed in class. You may use this as your starting point, but you do not have to be married to it. If you think of a better design, by all means use it!

This is my version of the program. I wrote it in a tremendous hurry, so it might have errors. (Test it and find out.)

When You Finish

Name the file in the form lastname_firstname_rsp.cpp; thus, if your name were Dwayne Johnson, you would name your file johnson_dwayne_rsp.cpp. Attach the .cpp file to an email and send the email to david.eisenberg@evc.edu.