Class Barge

java.lang.Object
  extended by Barge
All Implemented Interfaces:
Ship

public class Barge
extends java.lang.Object
implements Ship


Field Summary
 
Fields inherited from interface Ship
EAST, NORTH, SOUTH, WEST
 
Constructor Summary
Barge()
           
 
Method Summary
 char getCharForPoint(BoardPoint strike)
           Returns the character to display for a given BoardPoint.
 BoardPoint[] getExtent()
           Returns a newly-allocated array of BoardPoints, one for each BoardPoint this Ship occupies.
 int getFacing()
           Returns the direction this Ship is facing.
 java.lang.String getName()
          Returns "barge."
 BoardPoint getOrigin()
          Returns the origin point for this Ship.
 boolean isDestroyed()
           Returns true if this Ship is destroyed, false otherwise.
 boolean occupies(BoardPoint strike)
           Returns true if this Ship occupies the given space, false otherwise.
 void registerStrike(BoardPoint strike)
           Registers the result of a strike at the given point; records the strike and possibly destroys the ship.
 void setFacing(int facing)
           Sets the direction this ship is facing.
 void setOrigin(BoardPoint origin)
           Sets the origin of this ship as a BoardPoint.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Barge

public Barge()
Method Detail

isDestroyed

public boolean isDestroyed()
Description copied from interface: Ship
Returns true if this Ship is destroyed, false otherwise.

Specified by:
isDestroyed in interface Ship
Returns:
true if this Ship is destroyed, false otherwise.

getName

public java.lang.String getName()
Returns "barge."

Specified by:
getName in interface Ship
Returns:
"barge."

occupies

public boolean occupies(BoardPoint strike)
Description copied from interface: Ship
Returns true if this Ship occupies the given space, false otherwise.

Specified by:
occupies in interface Ship
Parameters:
strike - a BoardSpace that this Ship may or may not occupy
Returns:
true if this Ship occupies the given space, false otherwise.

registerStrike

public void registerStrike(BoardPoint strike)
Description copied from interface: Ship
Registers the result of a strike at the given point; records the strike and possibly destroys the ship.

Specified by:
registerStrike in interface Ship
Parameters:
strike - a BoardSpace

getOrigin

public BoardPoint getOrigin()
Description copied from interface: Ship
Returns the origin point for this Ship.

Specified by:
getOrigin in interface Ship
Returns:
the origin point for this Ship.

getFacing

public int getFacing()
Description copied from interface: Ship
Returns the direction this Ship is facing.

Specified by:
getFacing in interface Ship
Returns:
the direction this Ship is facing.

getExtent

public BoardPoint[] getExtent()
Description copied from interface: Ship
Returns a newly-allocated array of BoardPoints, one for each BoardPoint this Ship occupies.

Specified by:
getExtent in interface Ship
Returns:
an array of BoardPoints, as above.

getCharForPoint

public char getCharForPoint(BoardPoint strike)
Description copied from interface: Ship
Returns the character to display for a given BoardPoint. This is one of the following:
  1. (char)0, if this Ship does not occupy the given BoardPoint
  2. 'X', if this Ship has been struck at the given BoardPoint
  3. or a ship-dependent character (e.g. 'A' for aircraft carriers) if this Ship occupies the given point but has not been hit.

Specified by:
getCharForPoint in interface Ship
Returns:
a character, as above.

setOrigin

public void setOrigin(BoardPoint origin)
Description copied from interface: Ship
Sets the origin of this ship as a BoardPoint.

Specified by:
setOrigin in interface Ship

setFacing

public void setFacing(int facing)
Description copied from interface: Ship
Sets the direction this ship is facing. Precondition: facing is one of Ship.NORTH, Ship.EAST, Ship.SOUTH, Ship.WEST.

Specified by:
setFacing in interface Ship
Parameters:
facing - the direction this ship is facing.