Question: Create a multi - dimensional array of size 2 0 by 2 0 . Create the following methods; Create Board: This method will create the

Create a multi-dimensional array of size 20 by 20.
Create the following methods;
Create Board: This method will create the multi-dimensional array and initialize the values to zeros, such as this;
00000000000000000000
00000000000000000000
00000000000000000000
etc
Place Ship: This method will accept as parameters the starting coordinates of the ship, the type, and the direction.(vertical or horizontal) Then it will place the ship on the board by updating the array values to be dash characters, such as this "-"
The ships:
One Carrier of length 5One Battleship of length 4One Destroyer of length 2One Cruisers of length 3One Submarine length 3
Print Board: This method will output the contents of the board. Where there are ships, the dash character will be printed, where there are no ships, the zero character will be printed.
Fire: This method will accept two coordinates from the user. If there is a ship at that location, it will update the value to X for a hit. If there is no ship, it will update the character to "?" for miss.
A few exception cases to watch for:
If a ship starting coordinate is placed too close to the edge of the array, it will not fil (it would run off the end of the board)Ships should not collide / overlap

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!