/* Hi! I am struggling with a program to play Rock Paper Scissors. I am confused about how to calculate wins

/* Hi! I am struggling with a program to play Rock Paper Scissors. I am confused about how to calculate wins, looses, and draws. My TA said I need to use return in PlayOneRound method, but I still can’t totally understand it and I am too guilty to bother her agian. Sorry for letting you face these ugly code.*/

/*btw. Our professor restricts us to only use one scanner, that is the keyboard.
// CS312 Students. Do not change the following line.
// This is what our professor gave us to let computer make predictable random choice
RandomPlayer computerPlayer = buildRandomPlayer(args);
// CS312 students do no change the following line.
// Do not make any other Scanners.
Scanner keyboard = new Scanner(System.in); */

/* And I forgot to say, I just wrote following things under the class
public static final int playerWin = 0;
public static final int computerWin = 0;
public static final int numDraws = 0; */

//Play one round
public static int oneRound(Scanner keyboard, RandomPlayer computerPlayer){
System.out.println(playerName(keyboard) + “, please enter your choice for this round.”);
playerChoice(keyboard);
int playerChoice = playerChoice(keyboard);
int computerChoice = computerPlayer.getComputerChoice();
System.out.println(“Computer picked ” + computerChoice + “, ” + playerName(keyboard) +
“picked” + playerChoice(keyboard));
System.out.println();

if(computerChoice == ROCK && playerChoice == PAPER){
System.out.println(“PAPER covers ROCK. You win.”);
return playerWin;
} else if (computerChoice == ROCK && playerChoice == SCISSORS) {
System.out.println(“ROCK breaks SCISSORS. I win.”);
return computerWin;
} else if (computerChoice == PAPER && playerChoice == ROCK) {
System.out.println(“PAPER covers ROCK. I win.”);
return computerWin;
} else if (computerChoice == PAPER && playerChoice == SCISSORS) {
System.out.println(“SCISSORS cut PAPER. You win.”);
return playerWin;
} else if (computerChoice == SCISSORS && playerChoice == ROCK) {
System.out.println(“ROCK breaks SCISSORS. You win.”);
return playerWin;
} else if (computerChoice == SCISSORS && playerChoice == PAPER) {
System.out.println(“SCISSORS cut PAPER. I win.”);
return computerWin;
} else{
System.out.println(“We picked the same thing! This round is a draw.”);
return numDraws;
}
}

//Play rounds
public static void playRounds(Scanner keyboard, RandomPlayer computerPlayer){
for (int i =1; i < roundNumber(keyboard); i++){ System.out.println("Round" + i + "."); oneRound(keyboard, computerPlayer); } }

Complete Answer:

Get Instant Help in Homework Asap
Get Instant Help in Homework Asap
Calculate your paper price
Pages (550 words)
Approximate price: -
Open chat
1
Hello 👋
Thank you for choosing our assignment help service!
How can I help you?