CSCI 261 - Programming Concepts (C++)Spring 2017 - Assignment 03 - Rock, Paper, Scissors, Lizard, SpockQuick Links: Blackboard | Canvas | CS @ Mines | Cloud9 | Piazza | zyBooks |
|||||||||
| Home | Contact | Syllabus | Assignments | Schedule | Resources | | |||||||||
This assignment is due
by January 31, 2017 11:59pm.
In this homework assignment you have
the opportunity you will continue to use boolean expressions and
conditional statements.
Before you Begin Coding
It's easy for the logic in this assignment to get out of control very
quickly. We strongly recommend that you sit down with a pencil and
paper to sketch the flow of the logic that you'll need. Use pseudocode,
rough flowcharts, boxes, arrows, stickmen, or whatever means you need
to create a clear structure for the logic of your Rock, Paper,
Scissors, Lizard, Spock game.
After you have pseudocode for your solution, then create
yourself an empty project. You should know how to do this by now.
RPSLS
Most of you have likely played the classic game Rock, Paper,
Scissors but you can thank Sheldon for popularizing Rock,
Paper, Scissors, Lizard, Spock. Feel free to practice a few games to fully understand what
beats what. Below is the logic. An arrow points from X to Y following
the "X beats Y" pattern. You will notice there are more ways to win or
lose and a smaller possibility to tie.
![]() InstructionsYour goal is to implement a
Human-vs-Computer version of Rock, Paper, Scissors, Lizard, Spock.
We'll break this process into two steps.
Step One
Players will enter either R or r for
rock, P or p for paper, S
or s for scissors, L or l
for lizard, and K or k for spock.
Your program must then simply announce the winner. Note that your
program only needs to play one round of the game. We will add
repetition via loops soon. Here is an example interaction:
Welcome one and all to a round of Rock, Paper, Scissors, Lizard, Spock!
(Enter P, R, S, L, or K)
Player one: K Player two: r Spock vaporizes Rock. Player one wins! Here is another example:
Welcome one and all to a round of Rock, Paper, Scissors, Lizard, Spock!
(Enter P, R, S, L, or K)
Player one: p Player two: S Scissors beats paper. Player two wins! Your program must only prompt for two
inputs. It should also print a line following this pattern:
X beats Y. Player Z wins!
Where X and Y are one of "rock" or
"scissors" or "paper" or "lizard" or "spock" and Z is either "one" or
"two".
Step Two
Now that you have your RPSLS game working correctly, modify your code
to let the computer generate a random number for Player 2.
Specifically, generate a random number and then use
(randNumGenerated % 5)
to generate a 0 (Rock), 1 (Paper), 2 (Scissors), 3 (Lizard), or 4
(Spock) for the computer. Then assign 'r', 'p', 's', 'l', 'k' to the
computer's choice accordingly.
Once each player has made a decision, print out who wins or if the game is a tie. Example outputs follows:
Welcome one and all to a round of Rock, Paper, Scissors, Lizard, Spock!
(Enter P, R, S, L, or K)
Player one: R Computer: Lizard Rock beats Lizard. You win! Here is another example:
Welcome one and all to a round of Rock, Paper, Scissors, Lizard, Spock!
(Enter P, R, S, L, or K)
Player one: R Computer: Spock Spock beats Rock. Computer wins! Here is a final example:
Welcome one and all to a round of Rock, Paper, Scissors, Lizard, Spock!
(Enter P, R, S, L, or K)
Player one: S Computer: Scissors Scissors tie Scissors. Nobody wins. The solution you submit should provide
output like the last three example outputs.
Functional RequirementsYour solution must contiain the
following features in your code:
Grading Rubric
Your submission will be graded according to the following rubric.
Submission
Always, always, ALWAYS update the
header comments at the top of your main.cpp file. And if you ever get
stuck, remember that there is LOTS of help
available.
In summary, for homework due on
Tuesday, January 31 follow these specific steps:
This assignment is due
by January 31, 2017 11:59pm.
| |||||||||
Last Updated: 01/01/70 00:00
|