Question: Please answer correctly with explanation JAVA I need help writing Java code for this method public void throwDart(ThrowType type, int number) which simulates the action

Please answer correctly with explanation

JAVA

I need help writing Java code for this method "public void throwDart(ThrowType type, int number)" which simulates the action of the current player throwing one dart, adjusting the points as needed, and adjusts the players dart count. Switches to the other player if the current player uses up all darts or busts; does not switch to the other player if the current player wins. Does nothing if the game is already over. The number parameter is ignored in the case of type MISS, OUTER_BULLSEYE, or INNER_BULLSEYE. Busts means : the players score goes negative, gets to 1, or gets to zero but not ona double or inner bullseye, the player has gone bust, and their score is reset to whatever it was at the beginning of their turn, and the turn ends even if they haven't thrown all their darts. Here are some test cases: g = new DartGame(1, 100, 3); g.throwDart(DOUBLE, 10); System.out.println(g); g.throwDart(DOUBLE, 10); System.out.println(g); g.throwDart(DOUBLE, 10); System.out.println(g); g.throwDart(DOUBLE, 10); System.out.println(g); System.out.println(); // Expected: // Player 0: 100 Player 1: 80 Current: Player 1 Darts: 2 // Player 0: 100 Player 1: 60 Current: Player 1 Darts: 1 // Player 0: 100 Player 1: 40 Current: Player 0 Darts: 3 // Player 0: 80 Player 1: 40 Current: Player 0 Darts: 2

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 Programming Questions!