//  File: main1.C
//
//  Using the Tree template class

#include <iostream.h>
#include <iomanip.h>
#include <stdlib.h>
#include "bstring4.h"
#include "tree.h"

typedef Tree<BString> STree ;

main() {

try {
   cout << "Building the company tree...\n" ;

   // don't have to check for NULL...
   //
   STree *temp1 = new STree("Worker Bee #1") ;
   STree *temp2 = new STree("Worker Bee #2") ;
   STree *temp3 = new STree("Manager #1", *temp1, *temp2) ;

   STree empty ;
   STree *temp4 = new STree("Worker Bee #3") ;
   STree *temp5 = new STree("Manager #2", empty, *temp4) ;

   STree *temp6 = new STree("VP #1", *temp3, *temp5) ;

   STree *temp7 = new STree("Worker Bee #4") ;
   STree *temp8 = new STree("Manager #3", *temp7, empty) ;

   STree *temp9 = new STree("VP #2", *temp8, empty) ;

   STree company("President", *temp6, *temp9) ;

   cout << "\nPreorder Traversal:\n" ;
   company.preorder() ;
   cout << endl ;

   cout << "\nPostorder Traversal:\n" ;
   company.postorder() ;
   cout << endl ;

   cout << "\nInorder Traversal:\n" ;
   company.inorder() ;
   cout << endl ;
}

catch (MemoryError& e) {
   cerr << "MemoryError exception!" << endl ;
}

}
