/home/sjenks/NetBeansProjects/CS2/src/tester/BinaryTreeColors.java
  1 /*
  2  * This is to replicate the Binary tree tester but using colors as data.
  3  */
  4 
  5 
  6 package tester;
  7 
  8 import trees.BinaryTree;
  9 import trees.BinaryTreeCreationException;
 10 
 11 
 12 
 13 /**
 14  *
 15  * @author sjenks
 16  */
 17 public class BinaryTreeColors {
 18 
 19     /**
 20      * @param args the command line arguments
 21      */
 22     public static void main(String[] args) throws BinaryTreeCreationException {
 23         testerLR();//test determinsitic insertion +
 24         testerST();//test bst insertion +
 25         testerND();//test nondeterminsitic insertion +
 26         
 27         
 28     }
 29 
 30     private static void testerLR() {
 31        System.out.println ("Test LR...");
 32        BinaryTree<String, String> t = new BinaryTree<String,String>();
 33        System.out.println(">>> Creating empty tree.");
 34        System.out.println(">>>Adding elements to the tree directionally ... ");
 35        try{
 36            t.addLR("Red", null, "");
 37            t.addLR("White", null, "r");
 38            t.addLR("Blue", null, "l");
 39            t.addLR("Yellow", null, "rr");
 40            t.addLR("Black", null, "ll");
 41            t.addLR("Brown", null, "llr");
 42            t.addLR("Tangerine", null, "rl");
 43            t.addLR("Green", null, "lr");
 44            t.addLR("Purple", null, "lrr");
 45            t.addLR("Indigo", null, "lrl");
 46            t.addLR("Aqua", null, "lll");
 47            t.addLR("Orange", null, "lrrl");
 48            t.addLR("Pink", null, "lrrlr");
 49            t.addLR("GhostWhite", null, "lrlr");
 50            t.addLR("Gray", null, "lrlrr");
 51        }catch(BinaryTreeCreationException ex){
 52            ex.printStackTrace();
 53        }
 54        System.out.println (">>> Preorder");
 55        t.preorder();
 56        System.out.println (">>> Inorder");
 57        t.inorder();
 58        System.out.println (">>> Postorder");
 59        t.postorder();
 60        System.out.println (">>> Height = " + t.height());
 61     }
 62 
 63     private static void testerST() throws BinaryTreeCreationException {
 64         System.out.println("Test BST...");
 65         BinaryTree<String, String> t = new BinaryTree<String,String> ();
 66         System.out.println (">>> Creating an empty tree.");
 67         System.out.println (">>> Adding elements to a binary search tree...");
 68         t.addST("Red", null);
 69         t.addST("Blue", null);
 70         t.addST("White", null);
 71         t.addST("Black", null);
 72         t.addST("Green", null);
 73         t.addST("Tangerine", null);
 74         t.addST("Yellow", null);
 75         t.addST("Aqua", null);
 76         t.addST("Brown", null); 
 77         t.addST("Indigo", null);
 78         t.addST("Purple", null);
 79         t.addST("GhostWhite", null);
 80         t.addST("Orange", null);
 81         t.addST("Pink", null);
 82         t.addST("Gray", null);
 83                 
 84         System.out.println(">>> Preorder");
 85         t.preorder();
 86         System.out.println(">>> Inorder");
 87         t.inorder();
 88         System.out.println(">>> Postorder");
 89         t.postorder();
 90         System.out.println(">>> Height = " + t.height());
 91 
 92     }
 93 
 94     private static void testerND() {
 95         System.out.println("Test ND...");
 96         BinaryTree<String, String> t = new BinaryTree<String,String> ();
 97         System.out.println (">>> Creating an empty tree.");
 98         System.out.println (">>> Adding elements to the tree nondeterinistically...");
 99         t.addND("Red", null);
100         t.addND("Blue", null);
101         t.addND("White", null);
102         t.addND("Black", null);
103         t.addND("Green", null);
104         t.addND("Tangerine", null);
105         t.addND("Yellow", null);
106         t.addND("Aqua", null);
107         t.addND("Brown", null); 
108         t.addND("Indigo", null);
109         t.addND("Purple", null);
110         t.addND("GhostWhite", null);
111         t.addND("Orange", null);
112         t.addND("Pink", null);
113         t.addND("Gray", null);
114         System.out.println(">>> Preorder");
115         t.preorder();
116         System.out.println(">>> Inorder");
117         t.inorder();
118         System.out.println(">>> Postorder");
119         t.postorder();
120         System.out.println(">>> Height = " + t.height());
121     }
122     
123 }
124