/**
* This is class Node. *important: data is stored as integer for this exercise
*
* @author MUHAMMAD AZRI JASNI
* @version 10 OCTOBER 2012
*/
public class Node
{
private int data;//data carried by this node
private Node link; // reference to the next node in chain or null if there's none
/**
* Constructor for objects of class Node
*/
//I refer to http:://www.vias.org/javacourse/chap14_02.html
//and http://www.mycstutorials.com/articles/data_structures/linkedlists
public Node ()//default constructor
{}
public Node (int data)
{
this.data = data;
this.link = null;
}
public Node (int data, Node link)//if we want to specify the node to point to.
{
this.data = data;
this.link = link;
}
//methods: getData(), getLink(), setData(), setLink()
public int getData()
{
return data;
}
public void setData(int data)
{
this.data = data;
}
public Node getLink()
{
return link;
}
public void setLink(Node link)
{
this.link=link;
}
}