class EmptySea extends Ship You may wonder why EmptySea is a

class EmptySea extends Ship You may wonder why \"EmptySea\" is a type of ship. The answer is that the Ocean contains a Ship array, every location of which is, or can be, a reference to some Ship. If a particular location is empty, the obvious thing to do is to put a null in that location. But this obvious approach has the problem that, every time we look at some location in the array, we have to check if it is null. By putting a non-null value in empty locations, denoting the absence of a ship, we can save all that null checking. the absence of a ship, we can save alltha uchecking.

Solution

public class EmptySea extends Ship

{

EmptySea()

{

length=1;

}

boolean shootAt(int row,int column)

{

return false;

}

boolean isSunk()

{

return false;

}

public String toString()

{

super.toString();

}

}

 class EmptySea extends Ship You may wonder why \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site