-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
337 lines (321 loc) · 11.5 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
#include "info.hpp"//adding outputs if user enters something not in presentations
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <limits>
using namespace std;
void readFromFile(vector<Presentation_info> &); // reads all of the data from the file and inserts it into the class
void printAllData(vector<Presentation_info> &); // prints out all of the data with type of sorting
void sortRoom(vector<Presentation_info>&, string, string); // prints all rooms in the seleced day
void showCalendar(vector<Presentation_info> &);
void showDay(vector<Presentation_info> &, int);//show day from presentation
void showPresenters(vector<Presentation_info> &);
void showPresentation(vector<Presentation_info> &);
void sortTime(vector<Presentation_info>&, int,int);
void enterContinue();
int main() {
vector<Presentation_info> presentations;
readFromFile(presentations);
bool quit = false;
while (!quit) {
cout << "+------------------------------------+" << endl;
cout << "| National Learning Communities |" << endl;
cout << "| Conference |" << endl;
cout << "+------------------------------------+" << endl;
cout << "| |" << endl;
cout << "| Please select a category to |" << endl;
cout << "| search by: |" << endl;
cout << "| |" << endl;
cout << "| 1. Calendar or Time |" << endl;
cout << "| 2. Presenters or Email Lists |" << endl;
cout << "| 3. Presentations |" << endl;
cout << "| 4. Quit |" << endl;
cout << "| |" << endl;
cout << "+------------------------------------+" << endl;
cout << "Enter a number 1-4: ";
int choice;
cin >> choice;
switch (choice) {
case 1:
showCalendar(presentations);
system("clear");
break;
case 2:
showPresenters(presentations);
system("clear");
break;
case 3:
showPresentation(presentations);
system("clear");
break;
case 4:
system("clear");
cout << "See you soon!" << endl;
quit = true;
break;
default:
system("clear");
cout << "Invalid input. Please enter a number 1-4." << endl;
cin.clear();
cin.ignore();
break;
}
}
return 0;
}
void readFromFile(vector<Presentation_info> &presentations) {//getting info from file into vector
ifstream infile("data.txt");
if (!infile.is_open()) {
cerr << "Unable to open file." << endl;
return;
}
Presentation_info current_presentation;
string line;
while (getline(infile, line)) {
current_presentation.setDataInfo(infile, line);
if (line.empty()) {
presentations.push_back(current_presentation);
current_presentation = Presentation_info();
}
}
presentations.push_back(current_presentation);
infile.close();
}
void printAllData(vector<Presentation_info> &presentations) {
for (auto &presentation : presentations)
presentation.printPresentationData();
}
void showCalendar(vector<Presentation_info> &presentations) {//show calander based off selection made
string time;
int hour = 0,min = 0;
int choice;
system("clear");
do {
cout << "+--------------------------------------+" << endl;
cout << "| Calendar |" << endl;
cout << "+--------------------------------------+" << endl;
cout << "| |" << endl;
cout << "| 1. Day 1 |" << endl;
cout << "| 2. Day 2 |" << endl;
cout << "| 3. Full Calendar |" << endl;
cout << "| 4. Search by Time |" << endl;
cout << "| 5. Go Back |" << endl;
cout << "| |" << endl;
cout << "+--------------------------------------+" << endl;
cout << "Enter a number 1-5: ";
//sends user back to main menu
cin >> choice;
switch (choice) {//sub menu and choices
case 1:
system("clear");
showDay(presentations, choice);
break;
case 2:
system("clear");
showDay(presentations, choice);
break;
case 3:
system("clear");
printAllData(presentations);
enterContinue();
break;
case 4://search for presentations at certain time
system("clear");
time.clear();
hour = 0;
min = 0;
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "Please enter time when presentation starts: ";
getline(cin,time);
system("clear");
for(int i = 0; i < time.length(); i++){
if(isdigit(time[i])){
if(hour == 0){
if(isdigit(time[i+1])){
hour = stoi(time.substr(0,i+2));
time = time.substr(i+2);
i = 0;
}
else{
hour = stoi(time.substr(0,i+1));
time = time.substr(i+1);
i = 0;
}
}
else{
min = stoi(time.substr(i));
break;
}
}
}
sortTime(presentations,hour,min);
break;//while input is not a number and its less than 12 mins is 60
default:
system("clear");
cout << "Invalid input. Please enter a number 1-5." << endl;
cin.clear();
cin.ignore();
break;
}
} while (choice != 5);
}
void showDay(vector<Presentation_info> &presentations, int dayNum) {//show calander for specific room or all events
int choice;
string day = (dayNum == 1) ? "Friday" : "Saturday";
system("clear");
do {
cout << "+------------------------------------+" << endl;
cout << "| Please select a room for day " << dayNum << ": |" << endl;
cout << "+------------------------------------+" << endl;
cout << "| |" << endl;
cout << "| 1. Bayview |" << endl;
cout << "| 2. Nueces A |" << endl;
cout << "| 3. Nueces B |" << endl;
cout << "| 4. Laguna Madre |" << endl;
cout << "| 5. Aransas |" << endl;
cout << "| 6. Matagorda |" << endl;
cout << "| 7. Copano |" << endl;
cout << "| 8. Corpus A/B |" << endl;
cout << "| 9. Corpus C |" << endl;
cout << "| 10. Go Back |" << endl;
cout << "| |" << endl;
cout << "+------------------------------------+" << endl;
cout << "Enter a number 1-10: ";
cin >> choice;
switch (choice) {
case 1: sortRoom(presentations,day,"Bayview");
break;
case 2: sortRoom(presentations,day,"Nueces A");
break;
case 3: sortRoom(presentations,day,"Nueces B");
break;
case 4: sortRoom(presentations,day,"Laguna Madre");
break;
case 5: sortRoom(presentations,day,"Aransas");
break;
case 6: sortRoom(presentations,day,"Matagorda");
break;
case 7: sortRoom(presentations,day,"Copano");
break;
case 8: sortRoom(presentations,day,"Corpus A/B");
break;
case 9: sortRoom(presentations,day,"Corpus C");
break;
case 10:
break;
default:
system("clear");
cout << "Invalid input. Please enter a number 1-10." << endl;
cin.clear();
cin.ignore();
break;
}
} while (choice != 10);
enterContinue();
}
void showPresenters(vector<Presentation_info> &presentations){//searching by name or email list
bool in_list = false;
int choice;
string fullName,firstName,lastName;
system("clear");
do{
cout << "+------------------------------------+" << endl;
cout << "| Presenter names or Email lists |" << endl;
cout << "+------------------------------------+" << endl;
cout << "| |" << endl;
cout << "| 1. Search by presenter's name |" << endl;
cout << "| 2. Email list of presenters |" << endl;
cout << "| 3. Go Back |" << endl;
cout << "| |" << endl;
cout << "+------------------------------------+" << endl;
cout << "Enter a number 1-3: ";
cin >> choice;
switch(choice){
case 1:
system("clear");
cout << "Please enter the Presenters Name: ";//adding bool variable to check if any presentations contain the name used
cin.ignore(numeric_limits<streamsize>::max(), '\n');
getline(cin,fullName);
firstName = fullName.substr(0,fullName.find(' '));
lastName = fullName.substr(fullName.find(' ')+1);
for(auto &presentation : presentations)
presentation.searchName(firstName,lastName,in_list);
if(in_list == false)
cout << "Name not in presentation list." << endl << endl;//add a pause between output and menu
else
in_list = false;
enterContinue();
break;
case 2:
system("clear");
cout << endl << "Email List of all Presenters: " << endl << endl;//not clearing old outputs
for(auto &presentation : presentations)
presentation.emailList();
cout << endl;
enterContinue();
break;
case 3:
break;
default:
system("clear");
cout << "Invalid input. Please enter a number 1-3." << endl;
cin.clear();
cin.ignore();
break;
}
}while(choice !=3);
}
void showPresentation(vector<Presentation_info> &presentations) {//search by pres name
string name;
int count = 0;
system("clear");
cout << "Please enter the Presentation Name: ";//not pulling up presentation
cin.ignore(numeric_limits<streamsize>::max(), '\n');
getline(cin, name);
for (auto &presentation : presentations) {
if (presentation.getPresentationName() == name) {
count++;
presentation.printPresentationData();
}
}
if(count == 0)
cout << "Presentation not found!\n";
enterContinue();
}
void sortRoom(vector<Presentation_info>& presentations, string day, string room) {//sort by pres in a room
system("clear");
int count = 0;
for (auto &presentation : presentations) {
if (presentation.getDay() == day && presentation.getRoomName() == room) {
count++;
presentation.printPresentationData();
}
}
if(count == 0){
cout << "No presentations for this Room found in the list" << endl;//extra enter to continue
}
enterContinue();
}
void sortTime(vector<Presentation_info>& presentations, int hour, int min) {//sort what time pres are at
int count = 0;
for (auto &presentation : presentations) {
if(presentation.getStartHour() == hour && presentation.getStartMin() == min) {
count++;
presentation.printPresentationData();
}
}
if(count == 0){
cout << "Time not found in list!";//extra enter to continue
}
enterContinue();
}
void enterContinue()
{
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cout << "Press Enter to continue...";
cin.get();
system("clear");
}