133 lines
2.6 KiB
Java
133 lines
2.6 KiB
Java
/**
|
|
* <PRE>
|
|
* LLNode.java
|
|
*
|
|
* Revisions: 1.0 Sep. 21, 2002
|
|
* Created the LLNode class
|
|
* 1.1 Sep. 21, 2002
|
|
* Finished class
|
|
*
|
|
* </PRE>
|
|
*
|
|
* Collaboration Statement:
|
|
* I worked on the homework assignment alone, using only
|
|
* course materials.
|
|
*
|
|
* Created with JCreatorLE, some indents are off when viewed through notepad
|
|
* or EMACS
|
|
*
|
|
* @author <A HREF="mailto:gtg184g@mail.gatech.edu">Jose Manuel Caban</A>
|
|
* @version Version 1.1, Sep. 21, 2002
|
|
*/
|
|
|
|
public class LLNode {
|
|
|
|
/**
|
|
*holds the node data
|
|
*/
|
|
private Object data;
|
|
|
|
/**
|
|
*holds the location of the next node
|
|
*/
|
|
private LLNode next;
|
|
|
|
//nothing to debug that this will help with,
|
|
//but its in here for good measure
|
|
private static final boolean bDebug = false;
|
|
|
|
////////////////
|
|
//Constructors//
|
|
////////////////
|
|
|
|
/**
|
|
*Defaul LLNode Constructor
|
|
*both next and data are initialized to null
|
|
*/
|
|
public LLNode(){
|
|
setNext(null);
|
|
setData(null);
|
|
}
|
|
|
|
/**
|
|
*LLNode(Object)
|
|
*next initialized to null
|
|
*@param o the value to be given to data
|
|
*/
|
|
public LLNode(Object o){
|
|
setNext(null);
|
|
setData(o);
|
|
}
|
|
|
|
/**
|
|
*LLNode(Object,LLNode)
|
|
*@param o, the value of data
|
|
*@param next, the value of next
|
|
*/
|
|
public LLNode(Object o, LLNode next){
|
|
setNext(next);
|
|
setData(o);
|
|
}
|
|
|
|
///////////////////////
|
|
//Accessors/Modifiers//
|
|
///////////////////////
|
|
|
|
/**
|
|
*Accessor for data
|
|
*@return value of data
|
|
*/
|
|
public Object getData(){
|
|
return data;
|
|
}
|
|
|
|
/**
|
|
*Modifier for data
|
|
*@param the value for data
|
|
*/
|
|
public void setData(Object data){
|
|
this.data = data;
|
|
}
|
|
|
|
/**
|
|
*Accessor for next
|
|
*@return the next node
|
|
*/
|
|
public LLNode getNext(){
|
|
return next;
|
|
}
|
|
|
|
/**
|
|
*Modifier for next
|
|
*@param the new next node
|
|
*/
|
|
public void setNext(LLNode next){
|
|
this.next = next;
|
|
}
|
|
|
|
///////////
|
|
//Methods//
|
|
///////////
|
|
|
|
public String toString(){
|
|
return (data.toString());
|
|
}
|
|
|
|
/***********************************************/
|
|
|
|
/**
|
|
* Debugging main for class LLNode.
|
|
* This method will rigorously test my code.
|
|
*
|
|
* <br><br>
|
|
* @param args a String array of command line arguments.
|
|
*/
|
|
public static void main(String[] args) {
|
|
Integer bob = new Integer(5);
|
|
LLNode node = new LLNode(bob);
|
|
System.out.println(node);
|
|
|
|
}// end of main(String[] args)
|
|
|
|
}// end of class LLNode
|