/** * testing that builds a binary search tree of directory Entries * with students and faculty * and then searches the tree for specific people */ #include #include "Entry.h" #include "Student.h" #include "Faculty.h" #include "TreeNode.h" #include "BSTree.h" using namespace std; int main (int argc, char * argv []) { // test of various methods // constructors BSTree tree; Student stu1 ("Terry", "Walker", "walkert@math.grinnell.edu", 1970, "off-campus"); Student stu2 ("Barbara", "Ellen", "barbara@cs.grinnell.edu", 2002, "12-34-56"); Student stu3 ("Donna", "Marie", "donna@math.grinnell.edu", 1998, "3.1415926535"); Student stu4 ("Shamrock", "The Cat", "none", 3000, "varies"); Student stu5 ("Muffin", "The Cat", "none", 3000, "varies"); Faculty fac1 ("John", "Stone", "stone@cs.grinnell.edu", "Science 2418", 3181,"Computer Science", 1983); Faculty fac2 ("Henry", "Walker", "walker@cs.grinnell.edu", "Science 2420", 4208, "Computer Science", 1973); Faculty fac3 ("Janet", "Gibson", "gibson@grinnell.edu", "Science 0420", 3168, "Psychology", 1989); Faculty fac4 ("Samuel", "Rebelsky","rebelsky@cs.grinnell.edu", "Science 2427", 4410, "Computer Science", 1997); // insert entries to directory tree.insert(stu1); tree.insert(fac1); tree.insert(stu2); tree.insert(fac2); tree.insert(stu3); tree.insert(fac3); tree.insert(stu4); tree.insert(fac4); tree.insert(stu5); // print directory tree.print(); // check lookup Entry * ent; cout << "----------Searching for Barbara Ellen -- first entry----------\n"; ent = tree.lookup(new Entry ("Barbara", "Ellen", "")); if (ent == NULL) cout << "Barbara Ellen not found\n"; else cout << (* ent) << "\n"; cout << "----------Searching for Terry Walker -- last entry------------\n"; ent = tree.lookup(new Entry ("Terry", "Walker", "")); if (ent == NULL) cout << "Terry Walker not found\n"; else cout << (* ent) << "\n"; cout << "----------Searching for Muffin The Cat -- middle entry--------\n"; ent = tree.lookup(new Entry ("Muffin", "The Cat", "")); if (ent == NULL) cout << "Muffin, The Cat, not found\n"; else cout << (* ent) << "\n"; cout << "----------Searching for Muffin The Dog -- not present---------\n"; ent = tree.lookup(new Entry ("Muffin", "The Dog", "")); if (ent == NULL) cout << "Muffin, The Dog, not found\n"; else cout << (* ent) << "\n"; cout << "\nend of test suite\n"; }