Assignment 09


Write a simple rock-paper-scissors (aka, jan-ken-pon) game that plays only a single round.

Concepts: Review of conditionals, Strings, random numbers, methods.


• Ask the user to enter a move, either as a string or as an int.

You can have them enter one of the words "rock", "paper", or "scissors". Sample prompt:

  Enter your move (rock, paper, or scissors):

Or you can instead print a short menu explaining how the numbers 1, 2 and 3 map to "rock", "paper", or "scissors", and then ask them to enter the corresponding number. Something like this would work (though you could possibly do it clearly in a single line instead). Sample menu prompt:

  1) Rock
  2) Paper
  3) Scissors
  Enter the number of your move:

• Once you have the player's move, generate a random move for the computer. Each of the three possible move should be equally likely. Print the move as "rock", "paper", or "scissors" (not as a number!) on its own line. Sample:

  Computer's move: paper

• Then determine and display who won on another line. The rules are simple: paper beats rock, rock beats scissors, scissors beats paper. If the two moves are the same (for example, both rocks) then the game is a tie.

When displaying output, you may refer to the computer as "computer", "PC", "I", or "my". You may refer to the player as "player", "user", "human", or "you". (Case does not matter.) Print who "won" or "wins", or print that the game is a "tie" or "draw". Do not print who lost. Three sample outcomes:

  You won!

  The computer wins.

  Game was a tie.

The game should only play one round and then quit.

• Your program must include at least one static method in addition to main.


What to Submit

Upload your file to Tamarin.

Grading [9 points]

1 - Compiles
Your program compiles successfully (no errors) and follows Java coding standards.
2 - Input
Your user interface (UI) is clear on what input is required (format, range, etc) (0.5). Valid input is either (1, 2 or 3) or ("rock", "paper", or "scissors") (1.0). Program ends gracefully if input is invalid in any way (0.5).
1.5 - Computer move
Computer's move is random and evenly distributed (0.75). Computer's move is printed and labelled using one of the allowed terms described above (0.75).
3 - Result
You correctly print who won/wins, or that the game is a tie/draw.
1.5 - Method
You have at least one more method beyond main (that you actually call from within main).


This question usually isn't asked, but based on past experience, I'd recommend you double-check these things before submitting: