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: • 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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Can you please use Java.

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
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Could you please do it using java.

Solution
Bartleby Expert
SEE SOLUTION
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.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education