- Joined
- Oct 25, 2004
- Location
- 127.0.0.1
Hi Guys,
For my Uni course one of the exercises is to do a rock paper scissors game.. I've done how I think it should be done, and it works fine, however i'm sure there must be a simpler way to do it. I've attached my code and here is the task given on how it should function...
If anyone could point out an easier way to do it that would be good.
Thanks. J
For my Uni course one of the exercises is to do a rock paper scissors game.. I've done how I think it should be done, and it works fine, however i'm sure there must be a simpler way to do it. I've attached my code and here is the task given on how it should function...
If anyone could point out an easier way to do it that would be good.
Exercise 6.3
Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows:
1. The computer generates a random number in the range of 1 to 3. If the number is 1, then the computer has chosen Rock. If the number is 2, then the computer has chosen Paper. If the number is 3, then the computer has chosen Scissors. Do not display the computer‟s choice yet.
2. The user enters his or her choice of „rock, „paper‟, „scissors‟ or „quit‟ at the keyboard.
3. If the user has entered „quit‟, then continue at step 7.
4. The computer‟s choice is displayed.
5. A winner is selected according to the following rules:
a. If one player chooses Rock and the other player chooses Scissors, then Rock wins (The rock smashes the scissors)
b. If one player chooses Scissors and the other player chooses Paper, then Scissors wins (Scissors cut paper)
c. If one player chooses Paper and the other player chooses Rock, then Paper wins (Paper wraps rock)
d. If both players make the same choice, then it is a draw.
6. Go back to step 1.
7. Display the number of wins for the user and the computer as well as the number of draws.
Thanks. J