pseudocode.html Pseudocode for TakeShot Psuedocode BEGIN FUNCTION IF the shot is out of the ocean (grid) THEN Return Illegal shot result END Read value at position of shot from grid IF value is OK...

1 answer below »
zip file attached


pseudocode.html Pseudocode for TakeShot Psuedocode BEGIN FUNCTION IF the shot is out of the ocean (grid) THEN Return Illegal shot result END Read value at position of shot from grid IF value is OK THEN Increment misses Set position to Blownup Return Miss shot result END IF value is a Duplicate THEN Increment duplicates Return Duplicate shot result END /* If we make it here, then a boat must have been hit */ Increment hits for this boat Update position to boat hit IF number of hits for this boat is == BOAT_LENGTH THEN Increment sunk return Sunk shot result END Return Hit shot result END FUNCTION test0.txt The empty board 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Boat placement is accepted. Boat placement is accepted. Boat placement is accepted. Boat placement is rejected. Boat placement is rejected. Boat placement is rejected. The board with 3 boats 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 2 0 0 0 1 1 1 1 2 0 0 0 0 0 0 0 2 0 0 3 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 test1.txt The empty board 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 The board with 3 boats 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 2 0 0 0 1 1 1 1 2 0 0 0 0 0 0 0 2 0 0 3 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Shot: 10, 5 ILLEGAL Hits: 0 Misses: 0 Duplicates: 0 Boats Sunk: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 2 0 0 0 1 1 1 1 2 0 0 0 0 0 0 0 2 0 0 3 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Shot: 1, 3 HIT Hits: 1 Misses: 0 Duplicates: 0 Boats Sunk: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 2 0 0 0 101 1 1 1 2 0 0 0 0 0 0 0 2 0 0 3 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Shot: 5, 7 MISS Hits: 1 Misses: 1 Duplicates: 0 Boats Sunk: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 2 0 0 0 101 1 1 1 2 0 0 0 0 0 0 0 2 0 0 3 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 Shot: 1, 3 DUPLICATE Hits: 1 Misses: 1 Duplicates: 1 Boats Sunk: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 2 0 0 0 101 1 1 1 2 0 0 0 0 0 0 0 2 0 0 3 3 3 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 Shot: 2, 3 HIT Hits: 2 Misses: 1 Duplicates: 1 Boats Sunk: 0 0 0 0 0 0 0 0
Answered 2 days AfterMay 18, 2021

Answer To: pseudocode.html Pseudocode for TakeShot Psuedocode BEGIN FUNCTION IF the shot is out of the ocean...

Rushendra answered on May 21 2021
147 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here