Answered step by step
Verified Expert Solution
Question
1 Approved Answer
- Create Board: This method will create the multi-dimensional array and initialize the values to zeros, such as this; 000000000000000000000000000000000000000000000000000000000000etc - Place Ship: This method
- Create Board: This method will create the multi-dimensional array and initialize the values to zeros, such as this; 000000000000000000000000000000000000000000000000000000000000etc - 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 Battleship of length 8 - One destroyer of length 2 - Two cruisers of length 4 each - 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started