// Program to test the SearchTree class by constructing // two binary search trees and printing their structure and // contents. import java.util.*; public class SearchTreeClient { public static void main(String[] args) { Scanner console = new Scanner(System.in); SearchTree intTree = new SearchTree(); System.out.print("Next int? (0 to stop) "); int number = console.nextInt(); while (number != 0) { intTree.add(number); System.out.print("Next int? (0 to stop) "); number = console.nextInt(); } System.out.println(); System.out.println("Tree structure:"); intTree.printSideways(); System.out.println(); intTree.printInorder(); System.out.println(); console.nextLine(); SearchTree stringTree = new SearchTree(); System.out.print("Next word? (return to stop) "); String word = console.nextLine(); while (!word.isEmpty()) { stringTree.add(word); System.out.print("Next word? (return to stop) "); word = console.nextLine(); } System.out.println(); System.out.println("Tree structure:"); stringTree.printSideways(); System.out.println(); stringTree.printInorder(); } }