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 multidimensional array of size by
Create the following methods;
Create Board: This method will create the multidimensional array and initialize the values to zeros, such as this;
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 One Battleship of length One Destroyer of length One Cruisers of length One Submarine length
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 boardShips should not collide overlap
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
