import java.util.Scanner;

/**
* 
*
*/
public class Solution
{

	private Scanner input = null;
	private BinarySearchTree tree = null;
	
	/**
	* @param args
	*/
	public static void main(String[] args)
	{
		Solution solution = new Solution();
		solution.run();
	}

	public void run()
	{
		input = new Scanner( System.in );
		boolean isAplicationInUse = true;
		tree = new BinarySearchTree();
		
		while( isAplicationInUse )
		{
			int argument = -1;
			int number = -4;
			while( (argument!=1) && (argument!=2) && (argument!=3) && (argument!=4) )
			{
				System.out.printf("[restart(1) | add(2) | level(3) | quit(4)]: ");
				argument = input.nextInt();
			}
			
			if( argument == 2)
			{
				System.out.printf("[Please give me an int to add]: ");
				number = input.nextInt();
			}
			
			switch (argument)
			{
	
		        case 1:  tree.restart();
		        		 System.out.println("Tree restarted!");
		                 break;
		        case 2:  tree.add( number );
		        		 System.out.println();
		                 break;
		        case 3:  tree.printLevel();
		                 break;
		        case 4:  isAplicationInUse = false;
		        		 break;
	            default: System.out.printf("Nope%n");
	            		 break;
			}
		}
		System.out.println("Aplication closed!");
		input.close();
	}
}