/* * File : Node.java * * This file define the class 'Node'. * Each 'Node' has a 'VALUE' of type integer. * Each 'Node' has a 'NEXT' node of type 'Node'. * This class allows to create objects of type 'Node'. * An object of type 'Node' can then be used in a list. * */ /* This is the class declaration. */ public class Node { /* Those are two private variables of the class. */ /* They are only accessible from within the class. */ private int VALUE; // Define the value of the node. private Node NEXT; // Define the next node in the list. /* This is the class constructor method. */ /* This is the method called when you create an instance of the */ /* class 'Node' with the key word new. */ Node() { this.VALUE=0; // Set the value of the node to 0. this.NEXT=null; // Set the NEXT field to 'null'. } /* This is another constructor method. */ /* This one is using an argument. You can create a node with */ /* an initial value. */ Node(int value) { this.VALUE=value; // The keyword this refers to this.NEXT=null; // the current class. } /* This is a public method of the class. */ /* Is set the 'VALUE' of the node. */ public void setValue(int value) { this.VALUE=value; } /* This public method return the 'VALUE' of the node. */ public int getValue() { return this.VALUE; } /* This public method set the value of the 'NEXT' field. */ public void setNext(Node next) { this.NEXT=next; } /* A public method to get the value of the 'NEXT' field. */ public Node getNext() { return NEXT; } }