import java.util.Scanner;
import java.util.Random;
public class Project4 {
static Scanner kb = new Scanner(System.in);
public static void main(String[] args) {
Random rand = new Random();
char player, computer;
String choices = "BPS";
String computerChoice = "", playerChoice = "";
int numGames, game, wins = 0;
System.out.println("Hello! This is the game of Boulder, Parchment, Shears!");
System.out.println("How many games would you like to play? ");
numGames = kb.nextInt();
for (game = 1; game < numGames+1; game++) {
System.out.println("Game # " + game + ": ");
System.out.println("Please choose B, P, or S: ");
player = Character.toUpperCase(kb.next().charAt(0)); //grab player input, convert UPPER//
computer = "BPS".charAt(rand.nextInt(3));
switch (player) {
case 'B' -> playerChoice = "BOULDER";
case 'P' -> playerChoice = "PARCHMENT";
case 'S' -> playerChoice = "SHEARS";
}
computerChoice = switch (computer) {
case 'B' -> "BOULDER";
case 'P' -> "PARCHMENT";
case 'S' -> "SHEARS";
default -> computerChoice;
};
;
if (player == computer) {
System.out.println("It's a tie! ");
} else if
((player == 'B' && (computer == 'S')) ||
(player == 'P' && (computer == 'B') ||
(player == 'S' && (computer == 'P')))) {
System.out.println("Computer chose " + computerChoice + ". " + "You win with " + playerChoice + ".");
wins++;
} else if (player == 'B' || player == 'P' || player == 'S') {
System.out.println("Computer chose " + computerChoice + " ." + "You lost.");
}else {
System.out.println("Invalid Choice! Try again!");
}
} System.out.println("You won " + wins + " out of " + numGames + " games!");
System.out.println("Thanks for playing!");
}
}