Question: This is for Java Were going to be playing the game on a 10x10 grid. Each player will need to hide 5 ships: Aircraft carrier

This is for Java

Were going to be playing the game on a 10x10 grid. Each player will need to hide 5 ships:

Aircraft carrier - 5 squares long

Battleship - 4 squares long

Submarine - 3 squares long

Destroyer - 3 squares long

Patrol boat - 2 squares long

youre going to be writing a program that sets up the initial game board.

Your program should:

Denote ships by the first letter of their name (A for aircraft carrier, B for battleship, S for submarine, D for destroyer, and P for patrol boat).

Create a 10x10 grid of characters. Initially all squares of the grid should be set to E for empty.

Create a method that prints the current game board. Print a period in spaces that are empty. Print the ship letter in spaces that are occupied.

Create a second method that hides a ship. The method should take 5 parameters: the character representing the ships name, the length of the ship, and the (row, column) coordinate of the starting location of the ship, and a character indicating whether the ship should be placed horizontally beginning at the (row, column) coordinate or vertically beginning at the (row, column) coordinate.

In your main program, call the hide() method 5 times. Allow the user to enter the values passed to the method.

For the time being, you can assume that your user is smart enough not to place ships on top of each other. But it would be a great idea to think through how you could detect such misplacements.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!