Class Node

java.lang.Object
  |
  +--Node
All Implemented Interfaces:
java.lang.Comparable

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

A object of the class, Node has an object that contains a reference to an object of type Comparable and a reference to another Node. Allows a Node to be inserted into a list at construction. Supports linking a subsequent object to this Node, will return the reference to the next Node, or the reference to the data Object. However, the data object is immutable once the object is constructed. Students are not allowed to modify this class


Constructor Summary
Node(java.lang.Comparable initValue)
          Constructor builds the Node with the supplied parameter
Node(java.lang.Comparable initValue, Node initNext)
          Constructor builds the Node with the supplied parameters
 
Method Summary
 int compareTo(java.lang.Object obj)
          Compares value of Node to the parameter and returns: -1 if the Node is less than the parameter, 0 if the Node is equal to the parameter, and 1 if the Node is greater than the parameter
 java.lang.Comparable getData()
          Returns reference to the data value of the object
 Node getNext()
          Returns reference to the next Node
 void setNext(Node newNode)
          Sets the next reference of this object to the paramter object
 java.lang.String toString()
          Returns string representation of the object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Node

public Node(java.lang.Comparable initValue)
Constructor builds the Node with the supplied parameter
Parameters:
data - initValue must be of type Comparable

Node

public Node(java.lang.Comparable initValue,
            Node initNext)
Constructor builds the Node with the supplied parameters
Parameters:
initValue - must be of type Comparable
link - to a next Node, or null
Method Detail

getNext

public Node getNext()
Returns reference to the next Node
Returns:
next reference

setNext

public void setNext(Node newNode)
Sets the next reference of this object to the paramter object
Parameters:
newNodde - which is an object of the class Node

getData

public java.lang.Comparable getData()
Returns reference to the data value of the object
Returns:
Comparable reference

compareTo

public int compareTo(java.lang.Object obj)
Compares value of Node to the parameter and returns: -1 if the Node is less than the parameter, 0 if the Node is equal to the parameter, and 1 if the Node is greater than the parameter
Specified by:
compareTo in interface java.lang.Comparable
Returns:
1, 0, or -1

toString

public java.lang.String toString()
Returns string representation of the object
Overrides:
toString in class java.lang.Object
Returns:
String reference