Question: 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
![static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter the](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f050052c1a3_15666f05004c52b2.jpg)

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. Testing. Your goal is to pass all tests related to this method in the JUnit test class TestUtilities. These tests document the expected values on various cases: study them while developing your code. However, use the console application class RPSGame App if you wish (e.g., use the input and expected values from the JUnit tests) 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 CR, P. S)? S What does Doraemon play at round 2 (R. P. 3)? R What does Edward Scissorhands play at round 2 (R. P. 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. 5)? S What does Doraemon play at round 1 (R. P. S)? IR What does Edward Scissorhands play at round 2 R, P. 5)? 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 CR vs. S)) In this 2nd example run: The Round 1 result shows: Round 1: Doraemon wins (R vs. S). More precisely, R vs. S shown that rock wins scissors, despite the order of the players. That is the left-hand side of vs, alwnys shows the play that wins, nat 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') 7 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 get RPSGameReport must be a string like: Game over: Doraemon wins! [Round 1: Doraemon wins CR vs. S) : Round 2: Doraemon wins CR 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 :, I., 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. Hint. Study the 9 test cases in TestUtilites: they are arranged in a systematic yet not complete) way. Question. In order to exhaustively test this game, considering just how two players say Suyeon and Yuna may play in the two rounds, how many tests do we need? (Optionally, you may write extra test yourself an exercise.) package console apps; 2 30 import java.util.Scanner: 6 7 public class RPSGameApp public static void main(String[] args) { Scanner input = new Scanner(system.in); 12 System.out.println("Enter the name of player 1:"); 23 String pl = input.nextLine(); 14. 15 System.out.println("Enter the name of player 2:"); 16 String p2 = input.nextLine(); 17 18 /* Read inputs for round 1*/ 19 System.out.println("What does " + p1 + " play at round 1 (R, P, S)?"); 20 char piri = input.nextLine().charAt(); 17 reads a single character from user 21 System.out.println("What does " + P2 +" play at round 1 (R, P, S)?"); 22 char p2ri - input.nextLine().charAt(o); 17 reads a single character from user /* Read inputs for round 2 */ System.out.println("What does " + p1 + " play at round 2 (R, P, S)?"); 26 char pir2 = input.nextLine().charAt(0); // reads a single character from user System.out.println("What does " + P2 +" play at round 2 (R, P, S)?"); 28 char p2r2 = input.nextLine().charAt(0); 11 reads a single character from user 29 30 /* Get report from the utility method. */ 31 String report = Utilities.getRPSGameReport (p1, p2, piri, p2ri, pir2, p2r2); 32 33 System.out.println(report); 34 35 input.close(); 37 38 } 27 36 39 * Input parameters: "p1" is the name of player 1 p2 is the name of player 2 pirl is what player 1 plays in round 1 ('R', 'P', or 'S') p2r1' is what player 2 plays in round 1 ('R', or '5') pir2 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: pirip2r1', 'para', or p2r2 is one of the following characters: 'R' for rock, pl for paper, and 'S' scissors (case-sensitive) Hints: Compare character values using the relational operator =. Study the 9 test cases in Testutilites: they are arranged in a systematic (yet not exhaustive) way. Q. In order to exhaustively test this game, considering how two players may play in two rounds, how many tests do we need? (Optionally, you may write extra test yourself as an exercise.) Refer to you lab instructions for what the method should return. public static String getRPSGameReport(String pl, String P2, char piri, char pari, char pir2, 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. 1* Your implementation ends here. :/ return result
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
