Multi-Dimensional Arrays 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: o One Battleship of length 8 • One destroyer of length 2 o 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: o 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) o Ships should not collide / overlap

Programming Logic & Design Comprehensive
9th Edition
ISBN:9781337669405
Author:FARRELL
Publisher:FARRELL
Chapter6: Arrays
Section: Chapter Questions
Problem 5GZ
icon
Related questions
Question

Can you please use Java. Thank you! 

Multi-Dimensional Arrays
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 Battleship of length 8
o One destroyer of length 2
o Two cruisers of length 4 each
O
• 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
O
Transcribed Image Text:Multi-Dimensional Arrays 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 Battleship of length 8 o One destroyer of length 2 o Two cruisers of length 4 each O • 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 O
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,