-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenDatabase.h
More file actions
executable file
·93 lines (78 loc) · 1.9 KB
/
Copy pathGenDatabase.h
File metadata and controls
executable file
·93 lines (78 loc) · 1.9 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Jaden Heller
// 2328279
// jaheller@chapman.edu
// CPSC-350-01
// Assignment 6
#include "bst.h"
#include "Person.h"
//Abstracts bst.h and presents only the functions that will be
//needed for a person-Table (holds either students or faculty).
template<class T>
class GenDatabase{
public:
GenDatabase();
~GenDatabase();
BST<T> *bst = new BST<T>;
void add(T person);
bool remove(int ID);
bool contains(int ID);
bool isEmpty();
void printAll();
void printInfo(int ID);
void printInOrder();
void printAdvisingInfo(int ID);
T* returnPerson(int ID);
T getSucessor(T person);
T getRoot();
};
template<class T>
GenDatabase<T>::GenDatabase(){
}
template<class T>
GenDatabase<T>::~GenDatabase(){
delete bst;
}
template<class T>
void GenDatabase<T>::add(T person){
bst->insert(person);
}
template<class T>
bool GenDatabase<T>::remove(int ID){
return bst->deleteFromID(ID);
}
template<class T>
bool GenDatabase<T>::contains(int ID){
return bst->containsID(ID);
}
template<class T>
bool GenDatabase<T>::isEmpty(){
return bst->isEmpty();
}
template<class T>
void GenDatabase<T>::printAll(){
bst->printNodes();
}
template<class T>
void GenDatabase<T>::printInfo(int ID){
bst->printFromID(ID);
}
template<class T>
T* GenDatabase<T>::returnPerson(int ID){
return bst->returnKey(ID);
}
template<class T>
T GenDatabase<T>::getSucessor(T person){
T successor = bst->returnSucessor(person);
if (successor == person){ //If person has no successor (aka are their own successor)
successor = bst->getRoot(); //Then set the successor to be the person who is the root
}
return successor;
}
template<class T>
T GenDatabase<T>::getRoot(){
return bst->getRoot();
}
template<class T>
void GenDatabase<T>::printInOrder(){
bst->printInOrder();
}