CSCI 261 Programming Concepts (C++)

Winter/Spring 2012

Homework 7: Rock, Paper, Scissors... Fight!

Your goal is to implement a simple interactive rule-based system that addresses the Decision Problem.

Concepts

This assignment is designed to test your ability to design a game from scratch, given some requirements.

Simple Iterative Software Development

Whenever you are given a large problem, it is critical engineering skill to be able to analyze that problem and break it apart into manageable tasks. While the art of iterative software development is pretty deep, we'd like to show you some basics with this assignment.

In a nutshell, we encourage you to "fail fast" or "compile early and often." In other words, compile and run a blank program first. Does it work? Ok, now print a welcome message to the screen. Compile and run. Does that work? Ok, now capture player one's input. Does that work? No? Print what the player input to the screen and see what's wrong. Does it work now? Great, capture player two's input. Does that work? Great, now try to model the game rules. Try one case like "paper v rock" and see if the computer correctly declares the winner.

Get the idea? When learning how to program, it is important to not try to write a huge volume of code you think is right, and to fix each and every bug. You can do this, but we've found that while learning to program, this is an incredibly inefficient approach. You need what we call "immediate feedback". Write one line. Compile and run. Write another line. Compile and run.

Eventually, you'll be able to write more and more lines before compiling and running. If in doubt, start with the "write one line and compile" approach. But realize that this is merely our recommendation. A software engineer, much like an artist, must come up with a creative process that works for herself or himself. No one told Picasso how to paint -- he learned from masters before him and developed his own process by painting, painting, painting.

Pseudocode, Pencil and Paper: The Best Software Design Tools

It's easy for your logic in this assignment to get out of control very quickly. We strongly recommend you use pencil and paper to work out some potential scenarios, and to sketch the flow of the logic. Use pseudocode, rough flowcharts, boxes, arrows, stickmen, whatever means you need in order to reach a clear structure for the logic your game must implement.

Instructions

Your challenge is to implement a playable version of Rock, Paper, Scissors. Now, when we were thinking of changing this assignment to make it more exciting, we did a little digging only to find that there is a whole hardcore world of Rock, Paper, Scissors out there, even in Denver. It's frightening... there's even a DVD about this stuff. So, before you go off thinking how this is a kids game, think again. This is serious. (But if anyone asks, you're implementing a simple interactive rule-based system that addresses the theoretical Decision Problem.)

Requirements and Rubric

Your goal is to implement a two-player version of Rock, Paper, Scissors. Players will enter either R or r for rock, P or p for paper, and S or s for scissors. Your program must then simply announce the winner.

Note that your program should only play one round of the game. We will get to repetition and loops next week.

Here is an example interaction:

Welcome one and all to a round of Rock, Paper Scissors! (Enter P, R or S)
Player one: R
Player two: s
Rock beats scissors. Player one wins!

Do not #include <Windows.h> or color your output. Colors here are merely to draw your attention.

Here is another example:

Welcome one and all to a round of Rock, Paper Scissors! (Enter P, R or S)
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" and Z is either "one" or "two".

Yes, we and the RPS Society understand that this game is a little silly since each player can see what the other chooses, rather than each player choosing at the same time.

This work is worth 40 points.

Requirement Points Notes
Correct submission of src directory as a .zip file. 1
Place your name in the comment header in main.cpp 1
Correct datatypes used 6 if you use string remember to #include<string>
Proper use of constants 6 DRY: don't repeat yourself
Correctly prompts for only two inputs 4
Correctly accepts either upper or lower case letters 8 R or r, etc.
Correctly computes the winner 12
Correctly prints the required output 2

Concepts Exercised: compilation, I/O, making decisions, fun, application, declaring facts