assignment6
Class Node

java.lang.Object
  extended by assignment6.Node
All Implemented Interfaces:
java.lang.Comparable<Node>

public class Node
extends java.lang.Object
implements java.lang.Comparable<Node>

Represents a single square cell on the map.


Method Summary
 int compareTo(Node arg)
          Lexicographic sort order based on (x,y) coordinates
<T> T
getUserData()
          Retrieve the previously stored userData value.
 int getX()
          Get the X coordinate of this node on the map.
 int getY()
          Get the Y coordinate of this node on the map.
 boolean isAdjacent(Node other)
          Tests whether this node is adjacent to another (i.e., whether the naturalist can move from one to the other)
 boolean isGrassy()
          Returns true if node is covered with grass.
 boolean isShip()
          Return true if this node contains the ship.
<T> void
setUserData(T data)
          Store a value of an arbitrary type in this node.
 java.lang.String toString()
          Return a string representation of this node, "(x,y)"
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getX

public int getX()
Get the X coordinate of this node on the map.

Returns:
X coordinate of this node

getY

public int getY()
Get the Y coordinate of this node on the map.

Returns:
Y coordinate of this node

isAdjacent

public boolean isAdjacent(Node other)
Tests whether this node is adjacent to another (i.e., whether the naturalist can move from one to the other)

Parameters:
other -
Returns:
True if this and other are adjacent

toString

public java.lang.String toString()
Return a string representation of this node, "(x,y)"

Overrides:
toString in class java.lang.Object

isShip

public boolean isShip()
Return true if this node contains the ship.

Returns:

compareTo

public int compareTo(Node arg)
Lexicographic sort order based on (x,y) coordinates

Specified by:
compareTo in interface java.lang.Comparable<Node>

setUserData

public <T> void setUserData(T data)
Store a value of an arbitrary type in this node. This value has no significance for the Node class, but may be convenient for your use.

Type Parameters:
T - The type of data being stored.
Parameters:
data -

getUserData

public <T> T getUserData()
Retrieve the previously stored userData value. Returns null if no value has been stored.

Type Parameters:
T - Type of userData. Must be the same as what was originally stored (or a superclass).
Returns:

isGrassy

public boolean isGrassy()
Returns true if node is covered with grass.

Returns: