Question: USING JAVA package console_apps; import java.util.Scanner; import model.Utilities; public class RPSGameApp { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println(Enter the

USING JAVA

USING JAVA package console_apps; import java.util.Scanner; import model.Utilities; public class RPSGameApp {public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enterthe name of player 1:"); String p1 = input.nextLine(); System.out.println("Enter the nameof player 2:"); String p2 = input.nextLine(); /* Read inputs for round1*/ System.out.println("What does " + p1 + " play at round 1

(R, P, S)?"); char p1r1 = input.nextLine().charAt(0); // reads a single character

package console_apps;

import java.util.Scanner;

import model.Utilities;

public class RPSGameApp {

public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter the name of player 1:"); String p1 = input.nextLine(); System.out.println("Enter the name of player 2:"); String p2 = input.nextLine(); /* Read inputs for round 1*/ System.out.println("What does " + p1 + " play at round 1 (R, P, S)?"); char p1r1 = input.nextLine().charAt(0); // reads a single character from user System.out.println("What does " + p2 + " play at round 1 (R, P, S)?"); char p2r1 = input.nextLine().charAt(0); // reads a single character from user /* Read inputs for round 2 */ System.out.println("What does " + p1 + " play at round 2 (R, P, S)?"); char p1r2 = input.nextLine().charAt(0); // reads a single character from user System.out.println("What does " + p2 + " play at round 2 (R, P, S)?"); char p2r2 = input.nextLine().charAt(0); // reads a single character from user /* Get report from the utility method. */ String report = Utilities.getRPSGameReport(p1, p2, p1r1, p2r1, p1r2, p2r2); System.out.println(report); input.close(); }

} PLS NOTE THE CODE ABOVE IS RPSGameApp. DO NOT MODIFY!!!!!!!

package model;

public class Utilities { /* * Input parameters: * - `p1` is the name of player 1 * - `p2` is the name of player 2 * - `p1r1` is what player 1 plays in round 1 ('R', 'P', or 'S') * - `p2r1` is what player 2 plays in round 1 ('R', 'P', or 'S') * - `p1r2` is what player 1 plays in round 2 ('R', 'P', or 'S') * - `p2r2` is what player 2 plays in round 2 ('R', 'P', or 'S') * * Assumptions: * - `p1r1`, `p2r1`, `p1r2`, or `p2r2` is one of the following characters: * 'R' for rock, 'P' for paper, and 'S' scissors (case-sensitive) * public static String getRPSGameReport(String p1, String p2, char p1r1, char p2r1, char p1r2, char p2r2) { String result = ""; /* Your implementation of this method starts here. * Recall from Week 1's tutorial videos: * 1. No System.out.println statements should appear here. * Instead, an explicit, final `return` statement is placed for you. * 2. No Scanner operations should appear here (e.g., input.nextInt()). * Instead, refer to the input parameters of this method. */ /* Your implementation ends here. */

return result; } }

PLS NOTE THE CODE ABOVE SHOULD BE MODDIFY TO DO THE TASK

2.2.1 Method to Implement: getRPSGameReport Problem. You are asked to consider the rock-paper-scissors (RPS) game (for which it is assumed that you know how to play it). Rock is denoted by character 'R', paper by 'P', and scissors by 'S'. As a reminder: rock wins scissors, paper wins rock, and scissors wins paper. Let's consider two example runs (where the same two players swap the order from one game to another): Enter the name of player 1: Doraemon Enter the name of player 2: Edward Scissorhands What does Doraemon play at round 1 (R, P, S)? R What does Edward Scissorhands play at round 1 (R, P, S)? S What does Doraemon play at round 2 (R, P, S)? R What does Edward Scissorhands play at round 2 (R, P, S)? S Game over: Doraemon wins! [Round 1: Doraemon wins (R vs. S) ; Round 2: Doraemon wins (R vs. S)] Enter the name of player 1: Edward Scissorhands Enter the name of player 2: Doraemon What does Edward Scissorhands play at round 1 (R, P, S)? S What does Doraemon play at round 1 (R, P, S)? R What does Edward Scissorhands play at round 2 (R, P, S)? s What does Doraemon play at round 2 (R, P, S)? R Game over: Doraemon wins! [Round 1: Doraemon wins (R vs. S) ; Round 2: Doraemon wins (R vs. S)] In this 2nd example run: - The Round 1 result shows: Round 1: Doraemon wins (R vs. s). - More precisely, R vs. S shows that rock wins scissors, despite the order of the players. - That is, the left-hand side of vs. always shows the play that wins, not what player 1 (in this case Edward Scissorhands) plays. A similar argument also applies to the Round 2 result. Todo. Implement the Utilities.getRPSGameReport method. See the comments there for the input parameters and requirements. The String return value must conform to the expected format otherwise your code will fail some JUnit tests). Here are some hints for you: Read carefully the comments in the Utilitye class about what each input of method getRPSGameReport means. For example, invoking Utilities.getRPSGameReport("Suyeon", "Yuna", 'R', 'P', 'S', 'R') means: Suyeon is player 1, Yuna is player 2, player 1 plays rock and player 2 plays paper in Round 1, and player 1 plays scissors and player 2 plays rock in Round 2. Do not modify the console application class RPSGameApp given to you: the string return value of the utility method getRPSGameReport must be a string like: Game over: Doraemon wins! [Round 1: Doraemon wins (R vs. S) ; Round 2: Doraemon wins (R vs. S)] As illustrated in the above 2nd example run, the left-hand side of vs. always shows the play that wins, not what player 1 plays. Be mindful about the spellings (e.g., Game over, wins): they are case-sensitive. Be mindful about the single spaces between words and after symbols such as :, !, ., and .. After the phrase "Game over:'' comes the game result: it only shows who wins. Within the pair of square brackets [] comes the results of each round: it only declares who wins. Pls note that there are only two rounds meaning that ties can be done. Example: W IF A WINS ROUND 1 AND TIES IN ROUND2. A WINS IF A TIES ROUND 1 WITH B AND WINS ROUND2. A IS STILL THE WINNER BUT IF A TIES IN ROUND 1 AND ROUND 2. THEN IT IS A TIE! TIES AND WINS ARE THE ONLY things THAT ARE DISPLAYED. PLS NOTE: THE IF STATEMENTS AND THE LOOP ARE DONE IN THE MODEL MEANING THAT ONLY RETURN STATEMENTS SHOULD BE THERE AND NO PRINT STATEMENTS. MEANING THAT THEY ARE TWO CLASSES PRESENT WITH ONE LINKED TO THE OTHER

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!