ITEC 120 | Back to Assignment index page |
Assignment 2
- Rock, Paper, Scissors AGAIN Submit your program to your instructor's directory in the ITEC120 folder on neelix. |
Description: You will write a new program which will use the Player class you already wrote (for lab 10). This time, the user can play rock, paper, scissors against the computer.
For example:
Program outputs: | What's your name? |
User inputs: | Sam |
Program outputs: | Hello, Sam. How about a little game of Rock, Paper Scissors? You pick: R - Rock P - Paper S - Scissors Q - Quit |
User inputs: | P |
Program outputs: |
Sam: Paper Computer : Rock Sam WINS! Let's play again! Choose: |
User inputs: | S |
Program outputs: | Sam: Scissors Computer
: Scissors A TIE Let's play again! Choose: R - Rock P - Paper S - Scissors Q - Quit |
User inputs: | S |
Program outputs: | Sam: Scissors Computer
: Rock THE COMPUTER WINS! Let's play again! Choose: R - Rock P - Paper S - Scissors Q - Quit |
User inputs: | x |
Program outputs: | "x" is not
a valid command. Choose: R - Rock P - Paper S - Scissors Q - Quit |
User inputs: | r |
Program outputs: | Sam: Rock Computer
: Scissors Sam WINS! Let's play again! Choose: R - Rock P - Paper S - Scissors Q - Quit |
User inputs: | q |
Program outputs: |
---------------------------------- |
You will create two different files -- one for your Player class (you should already have this), and for your driver program (where the main method will be). You'll submit your Player.java and your program2.java files to your folder on neelix. Please remember to create a folder called RU03 inside your folder on neelix, and put Player.java and program2.java inside the RU03 folder. That way, the neelix collection script will be able to get your programs.
For full credit, your program should be able to handle both upper and lowercase input from the user. Your program should also validate input from the user. If the user does not enter R, P, S, or Q, give an error message and ask them to enter again. Your program should also output the final counts in good English. For example, you should not say "The computer won 1 games." or, "There were 1 ties.".