Advertisement
shad0wk1

Lab Exercise 5 Queue Node Class

Oct 20th, 2012
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.15 KB | None | 0 0
  1. /**
  2.  * This is class Node. *important: data is stored as Object for this exercise
  3.  *
  4.  * @author MUHAMMAD AZRI JASNI
  5.  * @version 10 OCTOBER 2012
  6.  */
  7. public class Node
  8. {
  9.     private Object data;//data carried by this node
  10.     private Node link; // reference to the next node in chain or null if there's none
  11.     /**
  12.      * Constructor for objects of class Node
  13.      */
  14.     //I refer to http:://www.vias.org/javacourse/chap14_02.html
  15.     //and http://www.mycstutorials.com/articles/data_structures/linkedlists
  16.    
  17.     public Node ()//default constructor
  18.     {}
  19.    
  20.     public Node (Object data)
  21.     {
  22.         this.data = data;
  23.         this.link = null;
  24.     }
  25.     public Node (Object data, Node link)//if we want to specify the node to point to.
  26.     {
  27.         this.data = data;
  28.         this.link = link;
  29.     }
  30.     //methods: getData(), getLink(), setData(), setLink()
  31.     public Object getData()
  32.     {  
  33.         return data;
  34.     }
  35.     public void setData(int data)
  36.     {
  37.         this.data = data;
  38.     }
  39.     public Node getLink()
  40.     {
  41.         return link;
  42.     }
  43.     public void setLink(Node link)
  44.     {
  45.         this.link=link;
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement