-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmptySea.java
58 lines (51 loc) · 1.39 KB
/
EmptySea.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package battleship;
/**
* Describes a part of the ocean that doesn’t have a ship in it.
*/
public class EmptySea extends Ship{
// Constructor
/**
* This zero-argument constructor sets the length variable to 1 by calling constructor in Super Class Ship
*/
public EmptySea() {
super(1);
}
// Methods
/**
* This method overrides shootAt(int row, int column) that is inherited
* from Ship, and always returns false to indicate that nothing was hit
* @param row of shooting at
* @param column of shooting at
* @return false always
*/
@Override
boolean shootAt(int row, int column) {
return false;
}
/**
* This method overrides isSunk() that is inherited from Ship, and always
* returns false to indicate that didn’t sink anything
* @return false always
*/
@Override
boolean isSunk() {
return false;
}
/**
* Returns the single-character '-' String to use in the Ocean’s print method
* this is the character to be displayed if a shot has been fired, but nothing has been hit
* @return the single char '-'
*/
@Override
public String toString() {
return "-";
}
/**
* Returns the string "empty"
* @return the type of ship as a String
*/
@Override
public String getShipType() {
return "empty";
}
}