/** 
 * SinglyLinkedListElement2
 * Paul Heider, Dan Schulte-Sasse, Jim Finnessy
 * March 24, 2001
 * V 1.0
 *
 * Stripped down version of the SinglyLinkedListElement used in class
 */

public class SinglyLinkedListElement2
{
    protected Object data; // value stored in this element
    protected SinglyLinkedListElement2 nextElement; // ref to next

    public SinglyLinkedListElement2(Object v,
                                   SinglyLinkedListElement2 next)
    // post: constructs a new element with value v,
    //       followed by next element
    {
        data = v;
        nextElement = next;
    }

    public SinglyLinkedListElement2(Object v)
    // post: constructs a new tail of a list with value v
    {
        this(v,null);
    }

    public SinglyLinkedListElement2 next()
    // post: returns reference to next value in list
    {
        return nextElement;
    }

    public void setNext(SinglyLinkedListElement2 next)
    // post: sets reference to new next value
    {
        nextElement = next;
    }

    public Object value()
    // post: returns value associated with this element
    {
        return data;
    }

    public void setValue(Object value)
    // post: sets value associated with this element
    {
        data = value;
    }
    
    public String toString()
    // post: returns string representation of element
    {
        return "<SinglyLinkedListElement2: "+value()+">";
    }
}

