Question Do not use system.out.print comments and no scanner operations. Do not use any java library classes or methods EXCEPT for java.util.Arrays class, class Character or Class String. here is the task description: Computational thinking for a software developer/computer programmer is a critical skill that is consistently applied. This lab requires you to develop a solution using Java object-oriented programming that simulates a basketball shootout game. Two players agree to limit the number of ball throw attempts to 3 throws each. The first player will make all three throw attempts (keep track of the successful baskets made where the ball goes into the basket). After the first player completes all three shots, the second player will make all three throw attempts. The player who makes the most baskets (gets the ball in the hoop) will be declared the winner. In the case of a tie, the tie counter is incremented by one. Then, the game is repeated until a winner can be determined. Note that the game can be repeated many times. The losing player of the shootout game will have to give the winning player a movie ticket(s). The number of movie tickets is determined by the total number of baskets made by the winner, less the total number of baskets made by the losing player. The losing player gives half of a movie ticket for every tied game (if there were any tied games). If the final calculated number of movie tickets has a decimal value, it should be rounded to the nearest whole number since you can't purchase half a ticket! Example: If the player-1 made a total of 3 baskets, and player- 2 made a total of 2 , and they had three tied games, the number of movie tickets would initially be 3-2=1, but increased by <span class="katex-display fleqn"><span class="katex"><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7278em;vertical-align:-0.0833em;"></span><span class="mord">3</span><span class="mspace" style="margin-right:0.2222em;"></span><span class="mbin">×</span><span class="mspace" style="margin-right:0.2222em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord"><span class="mord mathbf">0.5</span></span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord"><span class="mord mathbf">1.5</span></span></span></span></span></span>, making the owed number of tickets 2.5 which must be rounded up to 3 movie tickets.

O3ARCA The Asker · Computer Science

Do not use system.out.print comments and no scanner operations. Do not use any java library classes or methods EXCEPT for java.util.Arrays class, class Character or Class String. here is the task description:

Here is the starter code:

package lab5;

/**

*

* <p>Computational thinking for a software developer/computer programmer

* is a critical skill that is consistently applied. This lab requires you

* to develop a solution using Java object-oriented programming

* that simulates a basketball shootout game. </p>

* <p>Two players agree to limit the number of ball throw attempts to 3 throws each.

* The first player will make all three throw attempts

* (keep track of the successful baskets made where the ball goes into the basket). </p>

* <p> After the first player completes all three shots,

* the second player will make all three throw attempts.

* The player who makes the most baskets (gets the ball in the hoop) will be declared the winner.

* In the case of a tie, the tie counter is incremented by one.

* Then, the game is repeated until a winner can be determined.

* Note that the game can be repeated many times.</p>

* <p> The losing player of the shootout game will have to give the winning player a move ticket(s).

* The number of movie tickets is determined by the total number of baskets made by the winner,

* less the total number of baskets made by the losing player. </p>

* <p> The losing player gives half of a movie ticket for every tied game (if there were any tied games). </p>

* <p> If the final calculated number of movie tickets has a decimal value, it should be rounded to

* the nearest whole number since you can't purchase half a ticket!</p>

* <p> Example: If the player1 made a total of 3 baskets, and player2 made a total of 2,

* and they had three tied games, the number of movie tickets would initially be {@code 3-2=1},

* but increased by {@code 3 x 0.5=1.5}, making the owed number of tickets {@code 2.5} which must be

* rounded up to 3 movie tickets.</p>

*

* <p> Requirements: - Any use of Java library classes or methods (e.g., ArrayList,

* System.arraycopy) is forbidden. (That is, there must not be an import

* statement in the beginning of this class.) Violation of this requirement will

* result in a 50% penalty of your marks.</p>

* <p>

* - Use only if-statements and/or loops to manipulate primitive arrays (e.g.,

* int[], String[]).

* </p>

*/

public class Game {

// ALREADY IMPLEMENTED; DO NOT MODIFY

/**

* Two players agree to limit the number of ball throw attempts to 3 throws

* each. Constant value

*/

// ALREADY IMPLEMENTED; DO NOT MODIFY

private final static int NUMOFATTEMPT = 3;

/**

* The player1name is used to store the player name. The default value will be

* used if the name is not given to the player

* <p>

* The default value is <strong> <code>Unknown</code></strong>

* </p>

*/

// ALREADY IMPLEMENTED; DO NOT MODIFY

private String player1Name;

/**

* The player2name is used to store the player name. The default value will be

* used if the name is not given to the player

* <p>

* The default value is <strong> <code>Unknown</code></strong>

* </p>

*/

// ALREADY IMPLEMENTED; DO NOT MODIFY

private String player2Name;

/**

* The player1Attempt array is dynamically allocated at run time to store the

* result from player1 attempts

* <p>

* The default value is <strong> <code>false</code></strong> for each attempt

* </p>

*/

// ALREADY IMPLEMENTED; DO NOT MODIFY

private boolean[] player1Attempt;

/**

* The player2Attempt array is dynamically allocated at run time to store the

* result from player2 attempts

* <p>

* The default value is <strong> <code>false</code></strong> for each attempt

* </p>

*/

// ALREADY IMPLEMENTED; DO NOT MODIFY

private boolean[] player2Attempt;

/**

* The numberofTie is a counter to keep track of the number of tie games.

* <p>

* The default value is <strong> <code>zero</code></strong> before starting the

* game

*/

// ALREADY IMPLEMENTED; DO NOT MODIFY

private int numberofTie;

/**

* String Status keeps track of the current situation or status of the game.

* <p>

* This string changes during the game to reflect the game status.

* </p>

*/

// ALREADY IMPLEMENTED; DO NOT MODIFY

private String status;

// TODO: Your implementation starts here

// TODO: Your implementation starts here

/* Your implementation starts here

*/

/**

* Default constructor set the attributes to default values

* <p>

* <strong>Note: The constructor updated the game status after successfully

* constructing a new object from the game class </strong>

*/

public Game() {

// TODO: Your implementation starts here

}

/**

*

* <p>

* The constructor creates a new game by assigning player1name and player2 name

* attributes.

* </p>

* <p>

* If the player name is invalid, then the default value will be used.

* </p>

* <p>

* Also, the constructor makes sure other attributes are initialized to default

* values.

* </p>

* <p>

* <strong>Note: The constructor updated the game status after successfully

* constructing a new object from the game class </strong>

* </p>

*

* <p>

* Note: It is essential to read the API and check the JUnit test cases to know

* more about the default values for this game. Make sure you check

* </p>

*

* @param player1Name input string for player 1 name

* @param player2Name input string for player 2 name

*/

public Game(String player1Name, String player2Name) {

// TODO: Your implementation starts here

this.status = String.format("The game was initialized with player1(%s) and player2(%s)", this.player1Name,

this.player2Name);

}

/**

* The getter method allows us to get a player1 name for any game object.

* @return player 1 name for this game

*/

public String getPlayer1Name() {

// TODO: Your implementation starts here

}

/**

* The getter method allows us to get a player2 name for any game object.

* @return player 2 name for this game

*/

public String getPlayer2Name() {

// TODO: Your implementation starts here

}

/**

* The getter method allows us to get a player 1 attempts status.

* @return player 1 attempt status as an array of boolean

*/

public boolean[] getPlayer1Attempt() {

// TODO: Your implementation starts here

}

/**

* The getter method allows us to get a player 2 attempts status.

* @return player 2 attempt status as an array of boolean

*/

public boolean[] getPlayer2Attempt() {

// TODO: Your implementation starts here

}

/**

* The getter method allows us to get this game status

* @return this game status

*/

public String getGameStatus() {

// TODO: Your implementation starts here

}

/**

* <p>The setter method allows us to set player1 name for this game.</p>

* <p> After the game is created, this method will enable us to change the name of player1.</p>

* <p>

* <strong>Note: The method updated the game status after successfully

* updating player name </strong>

* </p>

* <p>

* Also, the method makes sure other attributes are initialized to default

* values if the player name is invalid

* </p>

* <p>

* Note: It is essential to read the API and check the JUnit test cases to know

* more about the default values for this game. Make sure you check

* </p>

*

*

* @param player1Name input string for player1 name

*/

public void setPlayer1Name(String player1Name) {

// TODO: Your implementation starts here

}

/**

* <p>The setter method allows us to set player2 name for this game.</p>

* <p> After the game is created, this method will enable us to change the name of player2.</p>

* <p>

* <strong>Note: The method updated the game status after successfully

* updating player name </strong>

* </p>

* <p>

* Also, the method makes sure other attributes are initialized to default

* values if the player name is invalid

* </p>

*

* <p>

* Note: It is essential to read the API and check the JUnit test cases to know

* more about the default values for this game. Make sure you check

* </p>

* @param player2Name input string for player2 name

*/

public void setPlayer2Name(String player2Name) {

// TODO: Your implementation starts here

}

/**

* The setter method allows us to set player1 attempt to success.

* <p>If the input value is outside the allowed range this method does nothing.</p>

* <p>

* <strong>Note: The method updated the game status after successfully

* updating player attempt </strong>

* </p>

* <p>

* Note: It is essential to read the API and check the JUnit test cases to know

* more about the default values for this game. Make sure you check

* </p>

* @param attemptNo integer input between 0 and 2

*/

public void setPlayer1AttempttoSucess(int attemptNo) {

// TODO: Your implementation starts here

}

/**

* The setter method allows us to set player1 attempt to fail.

* <p>If the input value is outside the allowed range this method does nothing.</p>

* <p>

* <strong>Note: The method updated the game status after successfully

* updating player attempt </strong>

* </p>

* <p>

* Note: It is essential to read the API and check the JUnit test cases to know

* more about the default values for this game. Make sure you check

* </p>

* @param attemptNo integer input between 0 and 2

*/

public void setPlayer1AttempttoFail(int attemptNo) {

// TODO: Your implementation starts here

}

/**

* The setter method allows us to set player2 attempt to fail.

* <p>If the input value is outside the allowed range this method does nothing.</p>

* <p>

* <strong>Note: The method updated the game status after successfully

* updating player attempt </strong>

* </p>

* <p>

* Note: It is essential to read the API and check the JUnit test cases to know

* more about the default values for this game. Make sure you check

* </p>

* @param attemptNo integer input between 0 and 2

*/

public void setPlayer2AttempttoSucess(int attemptNo) {

// TODO: Your implementation starts here

}

/**

* The setter method allows us to set player2 attempt to success.

* <p>If the input value is outside the allowed range this method does nothing.</p>

* <p>

* <strong>Note: The method updated the game status after successfully

* updating player attempt </strong>

* </p>

* <p>

* Note: It is essential to read the API and check the JUnit test cases to know

* more about the default values for this game. Make sure you check

* </p>

* @param attemptNo integer input between 0 and 2

*/

public void setPlayer2AttempttoFail(int attemptNo) {

// TODO: Your implementation starts here

}

/**

* <p>This method determines the number of tickets based on the player1 attempt,

* player2 attempts and the number of tied games.</p>

* <p> If the game is a tie game, this method returns zero and increments the number of ties by 1.</p>

*

* <p> Example: If the player1 made a total of 3 baskets,

* and player2 made a total of 2, and they had <strong>three tied games</strong>,

* the number of movie tickets would initially be {@code 3-2=1},

* but increased by {@code 3 x 0.5=1.5}, making the owed number of tickets {@code 2.5 }

* which must be rounded up to {@code 3 } movie tickets.

* <p>

* <strong>Note: The method updated the game status after successfully

* updating player attempt </strong>

* </p>

* <p>

* Note: It is essential to read the API and check the JUnit test cases to know

* more about the default values for this game. Make sure you check

* </p>

* @return integer number of movie tickets

*/

public int getNoofMovieTicket() {

// TODO: Your implementation starts here

}

}

Please follow test cases. Examples:

Transcribed Image Text: Computational thinking for a software developer/computer programmer is a critical skill that is consistently applied. This lab requires you to develop a solution using Java object-oriented programming that simulates a basketball shootout game. Two players agree to limit the number of ball throw attempts to 3 throws each. The first player will make all three throw attempts (keep track of the successful baskets made where the ball goes into the basket). After the first player completes all three shots, the second player will make all three throw attempts. The player who makes the most baskets (gets the ball in the hoop) will be declared the winner. In the case of a tie, the tie counter is incremented by one. Then, the game is repeated until a winner can be determined. Note that the game can be repeated many times. The losing player of the shootout game will have to give the winning player a movie ticket(s). The number of movie tickets is determined by the total number of baskets made by the winner, less the total number of baskets made by the losing player. The losing player gives half of a movie ticket for every tied game (if there were any tied games). If the final calculated number of movie tickets has a decimal value, it should be rounded to the nearest whole number since you can't purchase half a ticket! Example: If the player-1 made a total of 3 baskets, and player- 2 made a total of 2 , and they had three tied games, the number of movie tickets would initially be 3-2=1, but increased by , making the owed number of tickets 2.5 which must be rounded up to 3 movie tickets.
More
Transcribed Image Text: Computational thinking for a software developer/computer programmer is a critical skill that is consistently applied. This lab requires you to develop a solution using Java object-oriented programming that simulates a basketball shootout game. Two players agree to limit the number of ball throw attempts to 3 throws each. The first player will make all three throw attempts (keep track of the successful baskets made where the ball goes into the basket). After the first player completes all three shots, the second player will make all three throw attempts. The player who makes the most baskets (gets the ball in the hoop) will be declared the winner. In the case of a tie, the tie counter is incremented by one. Then, the game is repeated until a winner can be determined. Note that the game can be repeated many times. The losing player of the shootout game will have to give the winning player a movie ticket(s). The number of movie tickets is determined by the total number of baskets made by the winner, less the total number of baskets made by the losing player. The losing player gives half of a movie ticket for every tied game (if there were any tied games). If the final calculated number of movie tickets has a decimal value, it should be rounded to the nearest whole number since you can't purchase half a ticket! Example: If the player-1 made a total of 3 baskets, and player- 2 made a total of 2 , and they had three tied games, the number of movie tickets would initially be 3-2=1, but increased by , making the owed number of tickets 2.5 which must be rounded up to 3 movie tickets.
Community Answer
PQYMOB

&#12304;General guidance&#12305;The answer provided below has been developed in a clear step by step manner.Step1/4Answer : ---&gt; The solution code that meets the requirements :package lab5;public class Game { private final static int NUMOFATTEMPT = 3; private String player1Name = "Unknown"; private String player2Name = "Unknown"; private boolean[] player1Attempt = new boolean[NUMOFATTEMPT]; private boolean[] player2Attempt = new boolean[NUMOFATTEMPT]; public void setPlayer1Name(String name) { if (name != null &amp;&amp; !name.trim().isEmpty()) { player1Name = name; } } public void setPlayer2Name(String name) { if (name != null &amp;&amp; !name.trim().isEmpty()) { player2Name = name; } } public void play() { int player1Score = 0; int player2Score = 0; int numTieGames = 0; while (true) { // Player 1's turn for (int i = 0; i &lt; NUMOFATTEMPT; i++) { player1Attempt[i] = makeAttempt(); if (player1Attempt[i]) { player1Score++; } } // Player 2's turn for (int i = 0; i &lt; NUMOFATTEMPT; i++) { player2Attempt[i] = makeAttempt(); if (player2Attempt[i]) { player2Score++; } } // Determine the winner if (player1Score &gt; player2Score) { System.out.println(player1Name + " wins!"); printScore(player1Score, player2Score, numTieGames); return; } else if (player2Score &gt; player1Score) { System.out.println(player2Name + " wins!"); printScore(player2Score, player1Score, numTieGames); return; } else { System.out.println("Tie game!"); numTieGames++; } // Reset the scores and attempts for the next game player1Score = 0; player2Score = 0; Arrays.fill(player1Attempt, false); Arrays.fill(player2Attempt, false); } } private boolean makeAttempt() { // Return true if the attempt is successful, false otherwise return (Math.random() &lt; 0.5); } private void printScore(int winnerScore, int loserScore, int numTieGames) { double ticket = winnerScore - loserScore + numTieGames * 0.5; int roundedTicket = (int) Math.round(ticket); System.out.println("Winner gets " + roundedTicket + " movie ticket(s)"); }}Explanation:please refer above code :Explanation:Please refer to solution in this step.Step2/4Explanation of the code:--&gt; The Game class has ... See the full answer