CISS-110 Project 4
This is the game of Boulder, Parchment, Shears! Yes, the one from Critical Role based on Rock, Paper, Scissors.
This project deals with a range-based for
loop where we know the exact number of times a loop will iterate (perform the associated block of code). You will also use an if/else
construct to determine the winner.
Learning outcomes
- Implementing loops.
- Implementing conditional constructs.
- Using random numbers.
- Working with strings and string operations.
- Confirmation program produces desired results.
The standard rules apply. Boulder beats Shears, Shears beats Parchment, and Parchment beats Boulder.
Here is a set of variables to get you started:
char player, computer;
String choices = "BPS";
String[] names = {"BOULDER", "PARCHMENT", "SHEARS"};
int numGames, game, wins=0;
Begin by asking the user how many games they wish to play and setting up the for
loop based on that value. Within the loop is the general gameplay:
- Prompt and read for their choice. You should notify the user if they have made an invalid choice – which ends that game.
- Randomly select the computer’s choice.
- Determine the winner or a draw.
- Keep track of the player’s wins.
Here is a sample run that your program would produce. The user input is bold italic.
This is the game of Boulder Parchment Shears! How many games do you wish to play? 5 Game #1 Please choose B, P, or S: o Invalid choice! Game #2 Please choose B, P, or S: p It's a draw! Game #3 Please choose B, P, or S: s Computer wins with BOULDER! Game #4 Please choose B, P, or S: p Computer wins with SHEARS! Game #5 Please choose B, P, or S: s Computer had PARCHMENT. You won with SHEARS. You won 1 out of 5 games. Thanks for playing!
Submit the project to the Learning Management System as Project4_lastname.java.