/** A node in a tree
    <pre>
    $Id: Node.java,v 1.1 1999/05/13 05:34:48 jeremiah Exp jeremiah $
    $Log: Node.java,v $
    Revision 1.1  1999/05/13 05:34:48  jeremiah
    Initial revision

    </pre>
**/

public class Node{
    int value;
    Node left = null;
    Node right = null;
    /** Construct a new Node **/
    public Node(int value){
	this.value = value;
    }
    /** insert a value into the tree. If there is a node to the 
	left or right ask the appropriate one to insert the value, 
	otherwise create a new node for the value. 
    **/
    public void insert(int value){
	if (value > this.value){
	    if (right != null)
		right.insert(value);
	    else
		right = new Node(value);
	}
	else {
	    if (left != null)
		left.insert(value);
	    else 
		left = new Node(value);
	}
    }
    /** print out the tree first the left, then itself, then the right **/
    public void print(){
	if (left != null)
	    left.print();
	System.out.println(value);
	if (right != null)
	    right.print();
    }
}
