Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

class EmptySea extends Ship You may wonder why \"EmptySea\" is a type of ship. T

ID: 3929740 • Letter: C

Question

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.

Explanation / Answer

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();

}

}