Class Ship

java.lang.Object
  extended by Ship

public class Ship
extends java.lang.Object

This class denotes a ship object.


Constructor Summary
Ship()
          Default constructor for a ship object.
Ship(java.lang.String s, int xpos, int ypos, int length, boolean horiz)
          Contructor for a ship
 
Method Summary
 int getHits()
          Get the Hits value.
 boolean getIsHorizontal()
          Get the IsHorizontal value.
 int getLength()
          Get the Length value.
 java.lang.String getName()
          Get the Name value.
 int getXPosition()
          Get the XPosition value.
 int getYPosition()
          Get the YPosition value.
 boolean hasPoint(int x, int y)
          Returns true if the ship is present at point x,y.
 void hit()
          This method signifies a hit on the ship object,
 boolean isSunk()
          Returns true if the ship is sunk.
 void setHits(int newHits)
          Set the Hits value.
 void setIsHorizontal(boolean newIsHorizontal)
          Set the IsHorizontal value.
 void setLength(int newLength)
          Set the Length value.
 void setName(java.lang.String newName)
          Set the Name value.
 void setXPosition(int newXPosition)
          Set the XPosition value.
 void setYPosition(int newYPosition)
          Set the YPosition value.
 java.lang.String toString()
          Returns a string representing the ship.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Ship

public Ship()
Default constructor for a ship object.


Ship

public Ship(java.lang.String s,
            int xpos,
            int ypos,
            int length,
            boolean horiz)
Contructor for a ship

Parameters:
s - Name of the ship.
xpos - the x cordinate of the ship.
ypos - the y cordinate of the ship.
length - the length of the ship.
horiz - true if ship is to be placed horizontally, false otherwise
Method Detail

toString

public java.lang.String toString()
Returns a string representing the ship.

Overrides:
toString in class java.lang.Object
Returns:
a string object.

hasPoint

public boolean hasPoint(int x,
                        int y)
Returns true if the ship is present at point x,y.

Parameters:
x - the x-coordinate
y - the y-coordinate .
Returns:
true/false

hit

public void hit()
This method signifies a hit on the ship object,


isSunk

public boolean isSunk()
Returns true if the ship is sunk.

Returns:
true if ship is sunk/ false otherwise.

getIsHorizontal

public boolean getIsHorizontal()
Get the IsHorizontal value.

Returns:
the IsHorizontal value.

setIsHorizontal

public void setIsHorizontal(boolean newIsHorizontal)
Set the IsHorizontal value.

Parameters:
newIsHorizontal - The new IsHorizontal value.

getXPosition

public int getXPosition()
Get the XPosition value.

Returns:
the XPosition value.

setXPosition

public void setXPosition(int newXPosition)
Set the XPosition value.

Parameters:
newXPosition - The new XPosition value.

getYPosition

public int getYPosition()
Get the YPosition value.

Returns:
the YPosition value.

setYPosition

public void setYPosition(int newYPosition)
Set the YPosition value.

Parameters:
newYPosition - The new YPosition value.

getLength

public int getLength()
Get the Length value.

Returns:
the Length value.

setLength

public void setLength(int newLength)
Set the Length value.

Parameters:
newLength - The new Length value.

getHits

public int getHits()
Get the Hits value.

Returns:
the Hits value.

setHits

public void setHits(int newHits)
Set the Hits value.

Parameters:
newHits - The new Hits value.

getName

public java.lang.String getName()
Get the Name value.

Returns:
the Name value.

setName

public void setName(java.lang.String newName)
Set the Name value. :* @param newName The new Name value.