-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
195 lines (159 loc) · 3.34 KB
/
main.cpp
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
//Arafat Iqbal
//Main File
//CS202
//Program 3
//This file is the main file or the user interface,
//All functions are called from this file
#include "class.h"
#include "bst.h"
using namespace std;
int main()
{
//Menu Variables
int option = 0;
int choice = 0;
//Temp variables
int len = 0;
int num = 0;
char temp[MAX];
char temp2[MAX];
char temp3[MAX];
//Class objects
bst the_tree;
node the_node;
//Reading in from file
ifstream file;
file.open("info.txt");
//If FIle empty
if(!file)
{
cout << "Error" << endl;
}
else
{
cout << "Reading in..." << endl;
}
//While its in the file and there are items
while(file >> option)
{
if(choice == 1)
{
//Reading in Category
file.ignore();
file.getline(temp,100,',');
file.ignore(100,',');
//Reading in number
file >> num;
file.ignore(100,',');
//Reading in date
file.getline(temp2,100,',');
file.ignore(100,',');
//Reading in url
file.getline(temp3,100,',');
file.ignore(100,',');
zoom my_zoom(temp,num,temp2,temp3);
the_tree.input(&my_zoom);
}
if(choice == 2)
{
//Reading in category
file.ignore();
file.getline(temp,100,',');
file.ignore(100,',');
//Reading in number
file >> num;
file.ignore(100,',');
//Reading in assignment
file.getline(temp2,100,',');
file.ignore(100,',');
project my_project(temp,num,temp2);
the_tree.input(&my_project);
}
if(choice == 3)
{
//Reading in category
file.ignore();
file.getline(temp,100,',');
file.ignore(100,',');
//Reading in number
file >> num;
file.ignore(100,',');
//Reading in topic
file.getline(temp2,100,',');
file.ignore(100,',');
//Reading in length
file >> len;
file.ignore(100,',');
lecture my_lecture(temp,num,temp2,len);
the_tree.input(&my_lecture);
}
}
//Make sure it read in 100%
cout << "Reading in Complete! 100%" << endl;
file.close();
//Menu for inserting after reading in
int menu = 0;
do
{
cout<<" " <<endl;
cout<<"Welcome!" <<endl;
cout<<"Select Option Below: " << endl <<endl;
cout<<"\t1 - Add " <<endl;
cout<<"\t2 - " <<endl;
cout<<"\t3 - "<<endl;
cout<<"\t4 - Display" << endl;
cout<<"\t5 - Exit "<<endl <<endl;
cout<<"Menu Option : ";
cin>>menu; //Read in from the user
if(menu == 1)
{
option = 0;
//Add More Information in/ Update Thigns
cout << "What would you like to add?" << endl;
cout << "\t1 - Zoom Meeting Info" << endl;
cout << "\t2 - Homework Info" << endl;
cout << "\t3 - Lecture Info" << endl;
//Read in option
cin >> option;
cin.ignore(100,'\n');
if(option == 1)
{
//Creates Object,and uses operator overloading
//To Insert
//Getting a seg fault when inserting??
//Memory leak somewhere can't find it...
zoom the_zoom;
cin >> the_zoom;
the_tree.input(&the_zoom);
}
else if(option == 2)
{
//Creates Object,and uses operator overloading
//To Insert
project the_project;
cin >> the_project;
the_tree.input(&the_project);
}
else if(option == 3)
{
//Creates Object,and uses operator overloading
//To Insert
lecture the_lecture;
cin >> the_lecture;
the_tree.input(&the_lecture);
}
}
if(menu == 2)
{
}
if(menu == 3)
{
}
if(menu == 4)
{
the_tree.display();
}
}
while(menu != 5);
return 1;
}