import java.io.*;

/** tree takes no arguments. It read ints from stdin and add them to a tree. 
    It terminates on an empty input.
    <pre>
    $Id: Tree.java,v 1.3 1999/05/13 05:42:29 jeremiah Exp $
    $Log: Tree.java,v $
    Revision 1.3  1999/05/13 05:42:29  jeremiah
    Fixed comments

    Revision 1.2  1999/05/13 05:35:17  jeremiah
    Comments

    Revision 1.1  1999/05/13 05:30:13  jeremiah
    Initial revision
    
    </pre>
**/



public class Tree {
    
    public static BufferedReader in;
    public static Node node = null;;
    
    public static void main(String argv[]){
	
	try {
	    in = new BufferedReader(new InputStreamReader(System.in));
	    System.out.println("Enter int values, blank line to end");
	    String input;
	    int value;
	    while (true){
		try {
		    input = in.readLine();
		    value = Integer.parseInt(input);
		    if (node == null)
			node = new Node(value);
		    else 
			node.insert(value);
		} catch (NumberFormatException nfe){
		    if (input.equals("")){
			System.out.println("\ndone\n");
			if (node != null)
			    node.print();
			else System.out.println("Empty Tree");
			return;
		    }
		    else System.out.println("Not an Integer");
		}
	    }
	}  catch (IOException ioe){
	    System.out.println(ioe);
	}
    }
}

