/** * A generic node in a list. * A node has a link to the next node in the list and * some contents of type "Type". * @author Colin Potts * @date October 2008 */ public class Node { private Type data; private Node next; /** * Get the data from the node * @return the data contained in this node */ public Type getData() { return this.data; } /** * Get the next node following this one * @return the node after this node */ public Node getNext() { return this.next; } /** * Set or reset the data contained in this node * @param the data to be contained in this node */ public void setData(Type data) { this.data = data; } /** * Set or reset the next node following this one. If the node * already had a next node, the reference to it will be deleted * and overwritten with the new one. * @param the node after this node */ public void setNext(Node next) { this.next = next; } /** * toString creates a string corresponding to this node * @return the string representation of this node */ public String toString() { return "Node: " + getData(); } }