CS 117, Introduction to Computer Science

Rock, Paper, Scissors

Preview Version due Wednesday 10/10/01
Final Version due Wednesday, 10/17/01

Overview

Computerized Rock, Paper, Scissors! Here is how the game is normally played:

Two players opposite each other, tap their fist in their open palm three times (saying Rock, Paper, Scissors) and then show one of three possible gestures.

               Rock, Paper, Scissors Hand Positions
 

Your Project

Write a program to play RPS (Rock, Paper, Scissors) against a user. The computer will secretly randomly pick Rock, Paper, or Scissors. It will then ask a player to type in R, P, or S, and announce in a MessageBox who has won as well as the basis for determining the winner. For example:
Computer wins! Rock crushes scissors
Player wins! Paper wraps rock
Player wins! Scissors cut paper
Tie game! No one wins.
Be sure to allow the users to use lowercase as well as uppercase letters. Your program should include a loop that lets the user play again, if the user wants to.

More Details

This is a bigger program than the ones that you have been doing in the past. To help guide you along, you'll submit two versions: a pre-release and a final release. The pre-release version should do at least the following: In the pre-release, you do not need to worry about It's ok if the pre-release version has some bugs, but they should be documented at the top of the class.

All your code relating to the game should be in a class called RPSGame (or RPSGamePreRelease) which contains all your code relating to the game. Create another class called RPSGameMain (or RPSGameMainPreRelease) that contains a "main" method that does as little as possible.

RPSGame should have a constructor to set the initial values.

RPSGame should use both public and private methods. Keep each of your methods reasonably short. Here are some suggestions for some of the methods you might need:

Testing if two strings are equal

We'll talk about this more in class, but you shouldn't test if two strings are equal by using "==". Java will let you do this, but it's a poor idea. We'll talk about why later on. If you want to test if to strings are equal, you should use the "equals" method a string. For example:

String myName = "Dave";
String yourName = "Karen";
if (myName.equals(yourName))
  // do whatever

Parting Words:

Start early, and have fun!
(Graphic and some descriptions borrowed from http://www.rialto.k12.ca.us/frisbie/math/rps.html).