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.
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.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps