-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBST.h
More file actions
65 lines (55 loc) · 1.79 KB
/
BST.h
File metadata and controls
65 lines (55 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
Cosimo Gonnelli
This is the header for the tree class that manages a tree of categories
This is the tree manager class that holds 3 types of question groups (categories)
*/
#include"category.h"
//tree node
class b_node
{
public:
b_node();
~b_node();
b_node(const category & toCopy);
b_node *& goRight();
b_node *& goLeft();
void setRight(b_node * connect);
void setLeft(b_node * connect);
void display() const;
int compare(const b_node * toCompare) const;
category & getCategory();
protected:
b_node * right;
b_node * left;
category myCategory;
};
//BST manager class
class BST
{
public:
BST();
~BST();
int destroy();
void displayAll() const;
int insertCategory(category newCategory);
int insertMulti(char * categoryToAdd, mChoice *& newQuestion);
int insertTrueFalse(char * categoryToAdd, trueFalse *& newQuestion);
int retrieve(int random, char * category, question *& found);
//operator overloading implementations
BST operator + (const category & toAdd);
BST operator += (const category & toAdd);
bool operator == (const category & toCompare);
bool operator != (const category & toCompare);
friend istream & operator >> (istream & in, category & toAdd);
friend ostream & operator << (ostream & out, const BST & source);
protected:
int destroy(b_node *& root);
void displayAll(b_node * root) const;
int insertCategory(b_node *& root, b_node * toAdd);
int insertMulti(b_node *& root, char * categoryToAdd, mChoice *& toAdd);
int insertTrueFalse(b_node *& root, char * categoryToAdd, trueFalse *& toAdd);
int retrieve(b_node *& root, int random, char * category, question *& found);
bool check(b_node * root, const category & toCheck);
bool check2(b_node * root, const category & toCheck);
b_node * root; //pointer for the BST
};