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, and print it (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". Three sample outcomes:
You won! Computer won! Game was a tie.
The game should only play one round and then quit.
Your program must include at least one
What to Submit
Grading [10 points]
|~ztomasze Index :
TA Details: ICS111:
|Last Edited: 29 Sep 2009|
©2008 by Z. Tomaszewski.