|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Ship
public class Ship
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 |
---|
public Ship()
public Ship(java.lang.String s, int xpos, int ypos, int length, boolean horiz)
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 otherwiseMethod Detail |
---|
public java.lang.String toString()
toString
in class java.lang.Object
public boolean hasPoint(int x, int y)
x
- the x-coordinatey
- the y-coordinate .
public void hit()
public boolean isSunk()
public boolean getIsHorizontal()
public void setIsHorizontal(boolean newIsHorizontal)
newIsHorizontal
- The new IsHorizontal value.public int getXPosition()
public void setXPosition(int newXPosition)
newXPosition
- The new XPosition value.public int getYPosition()
public void setYPosition(int newYPosition)
newYPosition
- The new YPosition value.public int getLength()
public void setLength(int newLength)
newLength
- The new Length value.public int getHits()
public void setHits(int newHits)
newHits
- The new Hits value.public java.lang.String getName()
public void setName(java.lang.String newName)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |