|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectShip
Details of a ship and its status on the board
Field Summary | |
private Location[] |
body
Location of the body parts : an array 0..length-1 |
private int[] |
hit
Indices of the body parts destroyed |
private int |
hitNumber
Number of body parts destroyed |
private int |
length
Number of holes this ship occupies |
private String |
name
Name of the ship |
Constructor Summary | |
(package private) |
Ship(String n,
int l,
Location end,
int dir)
Creates a ship, and places it in a specified place. |
Method Summary | |
String |
detail()
|
boolean |
guess(Location l)
Carries out opponent's guess. |
private void |
hit(int i)
Marks body part i, as hit |
boolean |
isClash(Ship s)
Checks if two ships are in the same hole |
boolean |
isSunk()
|
int |
length()
|
Location |
locPart(int i)
Get Location of specified body part |
int |
numHit()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private String name
private int length
private Location[] body
private int[] hit
private int hitNumber
Constructor Detail |
Ship(String n, int l, Location end, int dir)
n
- Ship's namel
- Ship's lengthend
- Location of Ship's top, left end pointdir
- Direction to place the Ship (1=vertical, 0=horizontal)Method Detail |
public int length()
public Location locPart(int i)
i
- index of body part required
public String detail()
public boolean isSunk()
public int numHit()
private void hit(int i)
i
- number of body part to be destroyedpublic boolean guess(Location l)
l
- Location guessed
public boolean isClash(Ship s)
s
- Ship to compare with
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |