import java.util.Scanner; public class CollectionTree { private Scanner input = null; private Tree tree = new Tree(); /** * Start the execution of the solution * @param args Command line arguments */ public static void main(String args[]) { CollectionTree collectionTree = new CollectionTree(); collectionTree.run(); } /** * Run the solution. This method is called from main() */ public void run() { int userEntry = -1; this.input = new Scanner(System.in); while (userEntry != 0) { System.out.println("Welcome to the Collection Tree"); System.out.println("To reset the tree, press 1"); System.out.println("To add an element into the tree, press 2"); System.out.println("To get the level of the lowest leaf, press 3"); System.out.println("To exit, press 0"); userEntry = input.nextInt(); if (userEntry == 1) { tree.reset(); } else if (userEntry == 2) { tree.addNode(input); } else if (userEntry == 3) { tree.showTopLeaf(); } else if (userEntry != 0) { System.out.println("Invalid digit, please try again"); } } this.input.close(); } }