CSCI 261 - Programming Concepts (C++)

Spring 2017 - Assignment 03 - Rock, Paper, Scissors, Lizard, Spock

Quick 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.

RPSLS Image

Instructions


Your 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 Requirements



Your solution must contiain the following features in your code:
  • You MUST use an if/else if/else structure to determine who wins the game. You may use as many else ifs as you need. You WILL lose points for using multiple if statements to determine who wins. If this is unclear, ask on Piazza.


Grading Rubric


Your submission will be graded according to the following rubric.

Points Requirement Description
4 Labs completed
12 Human vs. Computer RPSLS Game is playable and meets functional requirements outlined above
4 (1) Comments used (2) Coding style followed (3) Appropriate variable names, constants, and data types used (4) Instructions followed (5) Assignment compiles


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:
  • create a directory called week03.
  • within week03, create three subdirectories: Lab03A, Lab03B, and A03.
  • within your new week03/Lab03A directory, copy in your main.cpp file from your Lab03A solution.
  • within your new week03/Lab03B directory, copy in your main.cpp file from your Lab03B solution.
  • within your new week03/A03 directory, copy in your main.cpp file from your A03 solution.
  • compress the week03 directory (see Step 3 here for details).
  • submit the week03.zip file to Blackboard (see Steps 5-10 here for details).
  • after you submit, download the file and double check it contains all that you think it contains!

This assignment is due by January 31, 2017 11:59pm.
Last Updated: 01/01/70 00:00


Valid HTML 4.01 Strict Valid CSS! Level Triple-A conformance, W3C WAI Web Content Accessibility Guidelines 2.0