Question: I need to finish this battleship.java class in codehs.com (7.1.7 part 6/7), by friday this week. I have everything else I just need this and

I need to finish this battleship.java class in codehs.com (7.1.7 part 6/7), by friday this week. I have everything else I just need this and I'm done.

https://media.cheggcdn.com/media/bcf/bcfba29f-0fba-48a2-9316-c47d93a4e229/phpuc0RSh

Here's the other classes for reference.

//Player class

public class Player

{

private static final int[] SHIP_LENGTHS = {2, 3, 3, 4, 5};

private static final int NUM_OF_SHIPS = 5;

private Ship[] ships;

private Grid myGrid = new Grid();

private Grid enemyGrid = new Grid();

private int shipCount = 0;

public Player()

{

ships = new Ship[NUM_OF_SHIPS];

for(int i = 0; i < NUM_OF_SHIPS; i++)

{

ships[i] = new Ship(SHIP_LENGTHS[i]);

}

}

public void printMyShips()

{

myGrid.printShips();

}

public void printOpponentGuesses()

{

enemyGrid.printStatus();

}

public void printMyGuesses()

{

myGrid.printStatus();

}

public void chooseShipLocation(Ship ship, int row, int col, int direction){

if(shipCount < 5)

{

ship.setLocation(row, col);

ship.setDirection(direction);

myGrid.addShip(ship);

shipCount++;

}

}

public void recordOpponentGuess(int row, int col){

if(myGrid.hasShip(row, col))

{

enemyGrid.markHit(row, col);

}

else

{

enemyGrid.markMiss(row, col);

}

}

public void askForGuess()

{

}

}

// You may need to make additions to your Player class in order

// to write your Battleship class

//Battleship class (as of now)

public class Battleship extends ConsoleProgram

{

public void run()

{

// Start here! This class should interact with the user

// to play the game of Battleship

// You only need to allow for the user to set up each player's

// ships and for each player to make a guess on the other player's grid

// Don't worry about finishing the whole game yet.

// You will probably need to make additions to the Player class to

// allow for this setting up and guessing

}

public int askForGuess()

{

}

}

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!