Question: You will see that there is raw code from 3 different files. at the end you can see the instruction to it aswell. Is done

You will see that there is raw code from 3 different files. at the end you can see the instruction to it aswell. Is done in Java RPSGameApp.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 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(); }

} TestUtilities.java

package junit_tests;

import static org.junit.Assert.*;

import org.junit.Test;

import model.Utilities;

public class TestUtilities { /* * Tests related to Utilities.getRPSReport */ /* Case 1.1 */ @Test public void testGetRPS_p1Win_p1Win() { String result = Utilities.getRPSGameReport("A", "B", 'R', 'S', 'R', 'S'); assertEquals("Game over: A wins! [Round 1: A wins (R vs. S) ; Round 2: A wins (R vs. S)]", result); } /* Case 1.2 */ @Test public void testGetRPS_p1Win_p1Lose() { String result = Utilities.getRPSGameReport("C", "D", 'P', 'R', 'R', 'P'); assertEquals("Game over: Tie! [Round 1: C wins (P vs. R) ; Round 2: D wins (P vs. R)]", result); } /* Case 1.3 */ @Test public void testGetRPS_p1Win_Tie() { String result = Utilities.getRPSGameReport("E", "F", 'S', 'P', 'R', 'R'); assertEquals("Game over: E wins! [Round 1: E wins (S vs. P) ; Round 2: Tie (R vs. R)]", result); } /* Case 2.1 */ @Test public void testGetRPS_p1Lose_p1Win() { String result = Utilities.getRPSGameReport("G", "H", 'R', 'P', 'P', 'R'); assertEquals("Game over: Tie! [Round 1: H wins (P vs. R) ; Round 2: G wins (P vs. R)]", result); } /* Case 2.2 */ @Test public void testGetRPS_p1Lose_p1Lose() { String result = Utilities.getRPSGameReport("I", "J", 'P', 'S', 'P', 'S'); assertEquals("Game over: J wins! [Round 1: J wins (S vs. P) ; Round 2: J wins (S vs. P)]", result); } /* Case 2.3 */ @Test public void testGetRPS_p1Lose_Tie() { String result = Utilities.getRPSGameReport("K", "L", 'S', 'R', 'P', 'P'); assertEquals("Game over: L wins! [Round 1: L wins (R vs. S) ; Round 2: Tie (P vs. P)]", result); } /* Case 3.1 */ @Test public void testGetRPS_Tie_p1Win() { String result = Utilities.getRPSGameReport("M", "N", 'R', 'R', 'S', 'P'); assertEquals("Game over: M wins! [Round 1: Tie (R vs. R) ; Round 2: M wins (S vs. P)]", result); } /* Case 3.2 */ @Test public void testGetRPS_Tie_p1Lose() { String result = Utilities.getRPSGameReport("W", "X", 'P', 'P', 'S', 'R'); assertEquals("Game over: X wins! [Round 1: Tie (P vs. P) ; Round 2: X wins (R vs. S)]", result); } /* Case 3.3 */ @Test public void testGetRPS_Tie_Tie() { String result = Utilities.getRPSGameReport("Y", "Z", 'S', 'S', 'S', 'S'); assertEquals("Game over: Tie! [Round 1: Tie (S vs. S) ; Round 2: Tie (S vs. S)]", result); } /* * Tests related to Utilities.getTaxReport */ @Test public void testGetTaxReport_invalid_01() { String result = Utilities.getTaxReport(3, 1000); assertEquals("Illegal Status: 3", result); } @Test public void testGetTaxReport_invalid_02() { String result = Utilities.getTaxReport(-1, 30000); assertEquals("Illegal Status: -1", result); } @Test public void testGetTaxReport_case_1_single() { String result = Utilities.getTaxReport(1, 6900); assertEquals("Single Filing: $690.00 (Part I: $690.00)", result); } @Test public void testGetTaxReport_case_1_married() { String result = Utilities.getTaxReport(2, 6900); assertEquals("Married Filing: $690.00 (Part I: $690.00)", result); } @Test public void testGetTaxReport_case_2_single() { String result = Utilities.getTaxReport(1, 12579); assertEquals("Single Filing: $1469.35 (Part I: $835.00, Part II: $634.35)", result); } @Test public void testGetTaxReport_case_2_married() { String result = Utilities.getTaxReport(2, 12579); assertEquals("Married Filing: $1257.90 (Part I: $1257.90)", result); } @Test public void testGetTaxReport_case_3_single() { String result = Utilities.getTaxReport(1, 22354); assertEquals("Single Filing: $2935.60 (Part I: $835.00, Part II: $2100.60)", result); } @Test public void testGetTaxReport_case_3_married() { String result = Utilities.getTaxReport(2, 22354); assertEquals("Married Filing: $2518.10 (Part I: $1670.00, Part II: $848.10)", result); } @Test public void testGetTaxReport_case_4_single() { String result = Utilities.getTaxReport(1, 59783); assertEquals("Single Filing: $11133.25 (Part I: $835.00, Part II: $3840.00, Part III: $6458.25)", result); } @Test public void testGetTaxReport_case_4_married() { String result = Utilities.getTaxReport(2, 59783); assertEquals("Married Filing: $8132.45 (Part I: $1670.00, Part II: $6462.45)", result); } @Test public void testGetTaxReport_case_5_single() { String result = Utilities.getTaxReport(1, 82947); assertEquals("Single Filing: $16924.25 (Part I: $835.00, Part II: $3840.00, Part III: $12249.25)", result); } @Test public void testGetTaxReport_case_5_married() { String result = Utilities.getTaxReport(2, 82947); assertEquals("Married Filing: $13111.75 (Part I: $1670.00, Part II: $7680.00, Part III: $3761.75)", result); } } Utilities.java

/* * 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) * * 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 p1, String p2, char p1r1, char p2r1, char p1r2, char p2r2) { String result = "";

return result; } }

You will see that there is raw code from 3 different files.

at the end you can see the instruction to it aswell. Is

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 RPSGameApp 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 (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 :, !, 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 as an exercise.) and : 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 RPSGameApp 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 (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 :, !, 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 as an exercise.) and

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!