-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
379 lines (339 loc) · 12.7 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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
#include "main.h"
int main()
{
/*General Variables Block*/
int menu_ID; //This variable is for testing the menu: this would be the class member's ID
char menu_input;
int tempID; //Variable for individual cases that need an ID input
/*Model Classes Block*/
provider choc_provider;
provider* provider_ptr;
member choc_member;
member* member_ptr;
manager choc_manager;
/*Structures Block*/
BST_member member_tree;
BST_provider provider_tree;
/* Service Block*/
service_list serve_list;
//service_list* serve_list_ptr = &serve_list;
service_directory serve_dir;
//load_member_data("data_member.txt", member_tree);
//load_provider_data("provider.txt", provider_tree);
print_header();
print_welcome();
menu_ID = query_ID();
/*
Provider Menu
*/
if (menu_ID == 1) {
do {
provider_menu();
cout << "Select a Function: ";
menu_input = query_menu();
switch(menu_input) {
case 's':
cout << "Please enter the ID of the member you would " <<
"like to check the status of: ";
tempID = query_ID();
if (!member_tree.display_by_ID(tempID)) {
cout << "Member ID Not Found..." << endl;
}
cout << endl << "Member status checked..." << endl;
break;
case 'i':
cout << "Please enter the ID of the member you would " <<
"like to display: ";
tempID = query_ID();
if (!member_tree.display_by_ID(tempID)) {
cout << "Member ID Not Found..." << endl;
}
cout << "Searching ID..." << endl;
break;
// case 'c':
// cout << "Charging Member..." << endl; *No built functionality?*
// break;
case 'd':
cout << "Displaying Provider Directory" << endl << endl;
cout << "List of services and codes as follows:" << endl << endl;
serve_dir.display_all();
cout << "Requesting Provider Directory..." << endl;
break;
case 'a':
choc_member.input();
member_ptr = &choc_member;
member_tree.add_new_member_(member_ptr);
cout << "Adding Member..." << endl;
break;
case 'r':
cout << "Please enter the ID of the member you would " <<
"like to remove: ";
tempID = query_ID();
if (!member_tree.remove_member_(tempID)) {
cout << "Unable to remove requested member..." << endl;
}
cout << "Removing Member..." << endl;
break;
case 'u':
cout << "Please Enter the ID of the member you would " <<
"like to update: ";
tempID = query_ID();
if (member_tree.search_by_ID(tempID)) {
member_ptr = member_tree.retrieve_member(tempID);
member_ptr->update_info();
cout << "Information updated..." << endl << endl;
}
else {
cout << "Member ID Not Found..." << endl;
}
cout << "Updating Member Information..." << endl;
break;
case 'o':
/*
No functionality yet
*/
cout << "Requesting Provider Report" << endl;
break;
case 'q':
cout << "Quitting..." << endl;
break;
default:
cout << "Unknown Command..." << endl << endl;
break;
}
} while (menu_input != 'q');
}
/*
Member Menu
*/
else if (menu_ID == 2) {
do {
member_menu();
cout << "Select a Function: ";
menu_input = query_menu();
switch (menu_input) {
case 's':
cout << "Please enter your member ID: ";
tempID = query_ID();
if (member_tree.search_by_ID(tempID)) {
member_ptr = member_tree.retrieve_member(tempID);
member_ptr->set_service_list();
}
else {
cout << "Member ID not found..." << endl;
}
cout << "Requesting service..." << endl << endl;
break;
case 'r':
cout << "Please enter your member ID: ";
tempID = query_ID();
if (member_tree.search_by_ID(tempID)) {
member_ptr = member_tree.retrieve_member(tempID);
member_ptr->display(cout);
}
else {
cout << "Member ID not found..." << endl;
}
cout << "Requesting Report..." << endl << endl;
break;
case 'q':
cout << "Quitting..." << endl << endl;
break;
default:
cout << "Unknown Command..." << endl << endl;
break;
}
} while (menu_input != 'q');
}
/*
Manager Menu
*/
else if (menu_ID == 3) {
do {
manager_menu();
cout << "Select a Function: ";
menu_input = query_menu();
switch (menu_input) {
case 'p':
/*
No functionality yet
*/
cout << "Printing Weekly Report" << endl;
break;
case 'a':
choc_member.input();
member_ptr = &choc_member;
member_tree.add_new_member_(member_ptr);
cout << "Adding Member" << endl;
break;
case 'd':
cout << "Please enter the ID of the member you would " <<
"like to remove: ";
tempID = query_ID();
if (!member_tree.remove_member_(tempID)) {
cout << "Unable to remove requested member..." << endl;
}
cout << "Removing Member" << endl;
break;
case 'k':
choc_provider.input();
provider_ptr = &choc_provider;
provider_tree.add_new_provider_(provider_ptr);
cout << "Adding Provider..." << endl;
break;
case 'r':
cout << "Please enter the ID of the provider you would " <<
"like to remove: ";
tempID = query_ID();
if (!provider_tree.remove_provider_(tempID)) {
cout << "Unable to remove requested provider..." << endl;
}
cout << "Removing Provider..." << endl;
break;
case 'u':
cout << "Please Enter the ID of the member you would " <<
"like to update: ";
tempID = query_ID();
if (member_tree.search_by_ID(tempID)) {
member_ptr = member_tree.retrieve_member(tempID);
member_ptr->update_info();
cout << "Information updated..." << endl << endl;
}
else {
cout << "Member ID Not Found..." << endl;
}
cout << "Updating Member Information..." << endl;
break;
case 's':
cout << "Please Enter the ID of the provider you would " <<
"like to update: ";
tempID = query_ID();
if (provider_tree.search_by_ID(tempID)) {
provider_ptr = provider_tree.retrieve_provider(tempID);
provider_ptr->update_info();
cout << "Information Updated..." << endl << endl;
}
else {
cout << "Member ID Not Found..." << endl;
}
cout << "Updating Provider Information..." << endl;
break;
case 'q':
cout << "Quitting..." << endl;
break;
default:
cout << "Unknown Command..." << endl << endl;
break;
}
} while (menu_input != 'q');
}
cout << "Thank you for choosing Chocoholics Anonymous!" << endl;
return 0;
}
void print_header()
{
cout << setw(50) << setfill('*') << "" << setfill(' ') << endl;
cout << "|" << setw(38) << "Chocoholics Anonymous Terminal" << setw(11) << "|" << endl;
cout << setw(50) << setfill('*') << "" << setfill(' ') << endl << endl;
}
void print_welcome()
{
cout << "Welcome to ChocAn!" << endl << endl;
cout << "[1] Provider Menu\n\n [2] Member Menu\n\n [3] Manager Menu\n\n";
cout << "Please enter a menu index from the above list: ";
}
void member_menu()
{
print_header();
cout << "s: Request provider service(s)" << endl;
print_line_break();
cout << "r: Request service report" << endl;
print_line_break();
cout << "q: Quit" << endl << endl;
print_line_break();
}
void provider_menu()
{
print_header();
cout << "s: Check Member Status" << endl;
print_line_break();
cout << "i: Search by ID" << endl;
print_line_break();
cout << "c: Charge Member for Service(s) [Nonfunctional]" << endl;
print_line_break();
cout << "d: Request Provider Directory" << endl;
print_line_break();
cout << "a: Add Member" << endl;
print_line_break();
cout << "r: Remove Member" << endl;
print_line_break();
cout << "u: Update Member Record" << endl;
print_line_break();
cout << "o: Request Provider Report" << endl;
print_line_break();
cout << "q: Quit" << endl << endl;
print_line_break();
}
void manager_menu()
{
print_header();
cout << "p: Print Weekly Report" << endl;
print_line_break();
cout << "a: Add Member" << endl;
print_line_break();
cout << "d: Remove Member" << endl;
print_line_break();
cout << "k: Add Provider" << endl;
print_line_break();
cout << "r: Remove Provider" << endl;
print_line_break();
cout << "u: Update Member Information" << endl;
print_line_break();
cout << "s: Update Provider Information [Nonfunctional]" << endl;
print_line_break();
cout << "q: Quit" << endl << endl;
print_line_break();
}
void print_line_break()
{
cout << setfill('-') << setw(20) << "" << endl;
}
/*****************************************************/
int query_ID()
{
int menu_ID;
cin >> menu_ID;
cout << endl;
return menu_ID;
}
char query_menu()
{
char tempInput;
cin.ignore(100, '\n');
tempInput = getchar();
cout << endl;
return tolower(tempInput);
}
/*****************************************************/
/*******************************************************
Loads member data from a text file into a member BST
********************************************************/
/*
void load_member_data(string file, BST_member& m_tree)
{
member temp_reader;
temp_reader.read_file(file, m_tree);
}
*/
/****************************************************
Loads provider data from a text file into a BST.
Breaks all of our code for some reason. Unable to
determine a solution
*****************************************************/
/*
void load_provider_data(string file, BST_provider& p_tree)
{
provider temp_reader;
temp_reader.read(file, p_tree);
}
*/