CMSC 202 Project 1
Rock, Paper, Scissors
Assigned Wed Sept 12
Program Due 10:00AM Sat Sept 22
Updates
Weight 6%
Objectives
To gain experience
  1. using Scanner( ) object for console input
  2. using System.out for console output
  3. writing methods in Java
  4. using objects/classes written by other programmers
Description
The game of Rock, Paper, Scissors is very popular among children and adults alike. Rock, Paper, Scissors (RPS for short) is a two player game in which each the players simultaneously extend their right hand in one of three gestures. The shape of a fist represents a Rock, an open flat hand with the palm down represents Paper, and having the index and middle finger spread apart represents a pair of Scissors. RPS is often used as a selection technique much like flipping a coin is used.

The winner is decided by these rules

  1. If both players gesture in the same manner the game is tied.
  2. Rock smashes Scissors; Rock wins
  3. Paper smothers Rock; Paper wins
  4. Scissors cut Paper; Scissors win

Strategies abound for those who take the game seriously. Check the web sites for the World RPS Society and the USA Rock Paper Scissors League. See the RPS Wikopedia entry for much more information.

Your assignment is to implement the game of RPS in which your program plays a series of RPS games against your program's user; decides who wins each game (or if there is a tie) in the series; then prints a summary of the outcomes for the series;

Project Policy
This project is considered an OPEN project. This means
  1. You should try as much as possible to complete the project by yourself.
  2. You may get assistance from anyone -- TAs, instructors, fellow students, relatives, friends, etc.
  3. You must document all outside help you get as part of your file header comment.
This DOES NOT mean
  1. that you may copy anyone else's code
  2. have someone else write your code for you
  3. submit someone else's code as your own
Such offenses are violations of the student code of academic conduct.
Project Requirements
  1. All code should be in a single file which MUST be named Project1.java which has a single public class also named Project1.
  2. You must declare your class to be part of the package named proj1.
    To make your file part of the proj1 package, your .java file must include the statement package proj1; as the first line of code.
    Don't worry... we'll discuss packages soon
  3. Your program must provide this basic functionality which should be implemented in main
    1. Prompt the user for the number of games (an integer) he wishes to play in the series
    2. For each game of RPS your program will choose Rock, Paper, or Scissors by using a random number generator (RNG); prompt the user for his RPS choice; output the choices of both players and declare the winner (or that the game was tied)
    3. When all games have been played, output a summary (the number of wins by each player and the number of ties) of the series of RPS games.
  4. Your program must validate all user input and re prompt the user if the input is invalid.
  5. Your program must accept the user's RPS choice as a string with any combination of upper- and lower-case characters.
  6. Your program must produce all output listed below in any reasonable, readable format.
  7. Your code must make appropriate use of functions (in keeping with good top-down design) and constants (to avoid magic numbers). Define functions and constants used by main within the Project1 class. See the Project Hints below regarding how to define these methods and constants.
Project Hints
  1. Be sure to make good use of the String class.
  2. Your program will be tested with a variety of good and BAD inputs. Get your project working with good input first. Then go back and put in the error checking and error handling.
  3. To generate random numbers for your programs choice, you will create a random number generator object with the statement
    	Random rng = new Random( ).
    
    You can obtain a random integer in the range 0 to N-1 with the statement
    	int x = rng.nextInt( N );
  4. To have access to the class definition for Random, your code must include the statement
    	import java.util.Random;
    
  5. Use the Scanner class in main for user input. To have access to the class definition for Scanner, your code must include the statement
    	import java.util.Scanner;
    
  6. Since main is (by definition) a static method, all methods and constants that are also defined within the Project1 class and used by main must also be defined as static. Constants and variables defined within main are of course local variables, so this requirement does not apply to them.
  7. To create a constant (like a #define in C), use the final modifier in addition to any other modifiers necessary.
  8. Arrays are not required (we haven't covered them yet), but if you're familiar with Java you may use arrays if you like.

Output

Your program must output the results for each "game" and cumulative statistics for the complete "series" of games.

For each game, your program must output

  1. Your program's choice of Rock, Paper, or Scissors
  2. The user's choice of Rock, Paper, or Scissors
  3. The result of the game
When all games in the series have been played, your program must output
  1. The number of games in the series
  2. The number games your program won
  3. The number of games the user won
  4. The number of games that were tied

Project Questions

In lieu of a project design assignment, you will be answering a few questions about your code to evaluate your understanding of objects and methods. Copy the file p1questions.txt from Mr. Frey's public directory /afs/umbc.edu/users/f/r/frey/pub/CMSC202/Proj1 then edit the file as indicated. Submit this file as part of your project along with your project code.

Grading

The grade for this project will be broken down as follows. A more detailed breakdown will be provided in the grade form you receive with your project grade.

10% - Project Questions

Be sure to submit your project questions file by the project due date.

80% - Correctness

This list may not be comprehensive, but everything on this list will be verified by the graders.

10% - Coding Standards

Your code adheres to the CMSC 202 coding standards as discussed and reviewed in class.
In particular, since this is your first CMSC 202 program, pay particular attention to the list below. Graders will check all applicable items in the coding standards.
  1. Your file header comments
  2. Your method header comments (particularly pre- and post-conditions)
  3. Method and variable names
  4. Code readability
  5. Limiting variable scope

Project Submission

Steps for Submission

  1. submit all files
  2. submitls to verify they are in the remote directory
Assuming you've used the recommended file names, then to submit your project, type the command submit cs202 Proj1 Project1.java p1questions.txt You may resubmit your files as often as you like, but only the last submittal will be graded and will be used to determine if your project is late. For more information, see the projects page on the course web site.

You can check to see what files you have submitted by typing

submitls cs202 Proj1

More complete documentation for submit and related commands can be found here.

Remember -- if you make any change to your program, no matter how insignificant it may seem, you should recompile and retest your program before submitting it. Even the smallest typo can cause errors and a reduction in your grade.