Allan Didier

Rock, Paper, Scissors with Strings

Goals

Write a Java program that can play the game Rock, Paper, Scissors with String variables.

Skills

  • String variables

Program Details

Make the following modifications to your Rock-Paper-Scissors game:

  1. Use Strings instead of numbers for the guesses.
    1. The user should input a string.
    2. The computer will still guess with a number, but convert the random number to a String.
    3. Compare the Strings when checking for the winner.
    4. Your program should ignore the letter case.
  2. If the user enters an invalid response, ask the user to enter a valid response. The program can then quit.

Again, test all combinations to make sure your game works properly. Test with both upper and lower case responses from the user. Also, test with invalid inputs.

Hints:

  • Duplicate your original Rock-Paper-Scissors game file before you begin. Don’t just modify your original program so that you have a functional program just in case Mr. Didier needs to see the game again for grading..
  • You cannot use the normal Boolean phrase “(String1 == String2)”. It does not work on Strings in Java. You must use the “String1.equals (String2)” phrase.
  • You can use either the String.toLowerCase or String.equalsIgnoreCase to ignore case.

Resources

Java Textbook

Chapter 3: Using Classes and Objects

Chapter 5: Conditionals and Loops

Bill Barnum's AP Computer Science A videos

AP College Board test prep videos