Java. I need help with making a program on Battleship. It needs to be a 2-player game of Battleship. I want to represent the game board using 2D-Arrays, one 2D-array variable for each of the players. I want the arrays to be type char or String. For representing the boats: Boats will be presented by the letter 'B' on the player's board. When adding boats to their board, players will represent their boats’ position, size, and orientation using four numbers one after the other, separated by spaces: The first number represents the X coordinate of the boat The second number represents the Y coordinate of the boat The third number represents the boat's size, that is how many spaces in the board the ship will take. This number will be between 1 and 6 The fourth number is the orientation of the boat: 0 for horizontal: the ship will grow from its coordinate right 1 for vertical: the ship will grow from its coordinate down I am trying to make the program function with the following: - Read an integer number representing the board size (always square) - Initialize all the coordinates of the board with "-" - Read an int representing how many boats each player will add to their board - Add the ships for each player (one player after the other) following the boat representation above. a. Example: 2 boats for each player b. Player 1 boat 1 c. Player 2 boat 1 d. Player 1 boat 2 e. Player 2 boat 2 After adding the boats to the board, I want it to print both player's boards. I want it to read a number representing how many shots will fire. Read two integers representing x and y coordinates for the player's shot. Repeat this step, alternating the player's turn until you fired all the shots. If the shot coordinate is outside the board, ignore the shot. Change the shots coordinate from either 'B' or '-' to 'X' Print both player's boards again. Print a String representing the final game state as follows: Draw, that is, there are boats left in both player's boards P1 Win: P2 has no more boats left, that is no more Bs on P2’s board). P1 still have boats P2 Win: P1 has no more boats left, that is no more Bs on P1’s board. P2 still have boats All destroyed: Both players have no boats left on their boards   If a boat grows past the bounds of the 2D array, I want it to "shrink" so it fits the play area. I want it to separate each player board using the tab scape character ('\t'). There is no spacing between each cell of the boards. I want it to add a new line between the two printing sequences. I want it to have a new line after printing the last board I also would like to make a method that recieves the players boards an dprints them to the console. I also would like to make a method that recieves both boards and determines who won. This method should not print to the console but rather return a value informing which player won (or draw or all destroyed). I need help with making a bomb program where the last shot of each player will have a special area-of-effect damage. The shot will cause damage on a radius of 2 in the horizontal and vertical directions and of radius 1 in the diagonal directions. Be aware of the index out of bounds issues that might occur. Example is attached.

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

Java. I need help with making a program on Battleship. It needs to be a 2-player game of Battleship. I want to represent the game board using 2D-Arrays, one 2D-array variable for each of the
players. I want the arrays to be type char or String.

For representing the boats:
Boats will be presented by the letter 'B' on the player's board. When adding boats to their
board, players will represent their boats’ position, size, and orientation using four numbers one
after the other, separated by spaces:
The first number represents the X coordinate of the boat
The second number represents the Y coordinate of the boat
The third number represents the boat's size, that is how many spaces in the board the ship will
take. This number will be between 1 and 6
The fourth number is the orientation of the boat:
0 for horizontal: the ship will grow from its coordinate right
1 for vertical: the ship will grow from its coordinate down

I am trying to make the program function with the following:
- Read an integer number representing the board size (always square)
- Initialize all the coordinates of the board with "-"
- Read an int representing how many boats each player will add to their board
- Add the ships for each player (one player after the other) following the boat representation
above.
a. Example: 2 boats for each player
b. Player 1 boat 1
c. Player 2 boat 1
d. Player 1 boat 2
e. Player 2 boat 2


After adding the boats to the board, I want it to print both player's boards.
I want it to read a number representing how many shots will fire.

Read two integers representing x and y coordinates for the player's shot. Repeat this step,
alternating the player's turn until you fired all the shots. If the shot coordinate is outside the
board, ignore the shot.
Change the shots coordinate from either 'B' or '-' to 'X'
Print both player's boards again.
Print a String representing the final game state as follows:
Draw, that is, there are boats left in both player's boards
P1 Win: P2 has no more boats left, that is no more Bs on P2’s board). P1 still have boats
P2 Win: P1 has no more boats left, that is no more Bs on P1’s board. P2 still have boats
All destroyed: Both players have no boats left on their boards

 

If a boat grows past the bounds of the 2D array, I want it to "shrink" so it fits the play area.
I want it to separate each player board using the tab scape character ('\t'). There is no spacing between each cell of the boards.
I want it to add a new line between the two printing sequences.
I want it to have a new line after printing the last board

I also would like to make a method that recieves the players boards an dprints them to the console.
I also would like to make a method that recieves both boards and determines who won. This method should not print to the console but rather return a value informing which player won (or draw or all
destroyed).

I need help with making a bomb program where the last shot of each player will have a special area-of-effect damage. The shot will cause damage on a radius of 2 in the horizontal and vertical directions and of radius 1 in the diagonal directions. Be aware of the index out of bounds issues that might occur.

Example is attached.

Input
Output
10
2
-BBB-
1 2 2 0
7 6 2 1
1 1 10
8 3 3 1
2
9 3
1 1
------B---
---
--B--B---
8 5
---B-
6 6
-XBB-
------X--
-XXX--
---
-XXXXX-
-----X-
---
-----XXX-- ----XXX---
------X---
--XXXXX--
-
--ХXXX---
P1 Won!
Transcribed Image Text:Input Output 10 2 -BBB- 1 2 2 0 7 6 2 1 1 1 10 8 3 3 1 2 9 3 1 1 ------B--- --- --B--B--- 8 5 ---B- 6 6 -XBB- ------X-- -XXX-- --- -XXXXX- -----X- --- -----XXX-- ----XXX--- ------X--- --XXXXX-- - --ХXXX--- P1 Won!
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

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