-
Notifications
You must be signed in to change notification settings - Fork 0
/
GPACalculatorDriver.h
1028 lines (880 loc) · 25.1 KB
/
GPACalculatorDriver.h
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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using namespace std;
#pragma region fields
//These are the fields that the header file uses
//Each special course is stored here
//The course manager stores representations of these courses along with the
//custom courses and previous gpa info
InputValidator iv;
CourseManager cm;
Phy2048 phy2048;
Phy2049 phy2049;
Cot3100 cot3100;
COP3502 cop3502;
Chm2045 chm2045;
MAC2311 mac2311;
MAC2312 mac2312;
MAC2313 mac2313;
MAS3114 mas3114;
COP3503 cop3503;
#pragma endregion
#pragma region helper functions
#pragma region input getters
//This returns an instance of input validator
InputValidator getInputValidator() {
return iv;
}
//The following getters have checks to make sure that the input is valid
//This gets a gpa value from user
double getGPA() {
double inputPreviousGPA = -1;
do {
cout << "Please enter GPA: " << endl;
inputPreviousGPA = iv.getDouble();
if (inputPreviousGPA < 0 || inputPreviousGPA > 4) {
cout << "GPA must be between 0.0 and 4.0" << endl;
}
cout << endl;
} while (inputPreviousGPA < 0 || inputPreviousGPA > 4);
return inputPreviousGPA;
}
//gets a credit hours value from user
int getCreditHours() {
int inputCreditHours = -1;
do {
cout << "Please enter the amount of credit hours: " << endl;
inputCreditHours = iv.getInt();
if (inputCreditHours < 0) {
cout << "The number of credit hours must be 0 or greater" << endl;
}
cout << endl;
} while (inputCreditHours < 0 || inputCreditHours == NULL);
return inputCreditHours;
}
//gets a string for the course name
string getCourseName() {
string courseName = "";
do {
cout << "Please enter the name of the course: " << endl;
courseName = iv.getString();
if (courseName.empty()) {
cout << "Invalid course name: " << courseName.c_str() << endl;
}
cout << endl;
} while (courseName.empty());
return courseName;
}
//gets a final grade value from user
double getFinalGrade() {
//we introduce a bug if the grade is 0
cout << "Please enter the grade for the final:" << endl;
double finalGrade = -1;
while (finalGrade < 0) {
finalGrade = iv.getDouble();
if (finalGrade < 0) {
cout << "Grade must be 0 or greater" << endl;
}
cout << endl;
}
return finalGrade;
}
//gets an exam grade value from user
//the parameter is to output which exam
double getExamGrade(int examNum) {
cout << "Please enter the grade for exam " << examNum << endl;
double examGrade = -1;
while (examGrade < 0) {
examGrade = iv.getDouble();
if (examGrade < 0) {
cout << "Grade must be 0 or greater" << endl;
}
cout << endl;
}
return examGrade;
}
//gets a quiz grade value from the user
//the parameter is to output which quiz
double getQuizGrade(int quizNum) {
cout << "Please enter the grade for quiz " << quizNum << endl;
double quizGrade = -1;
while (quizGrade < 0) {
quizGrade = iv.getDouble();
if (quizGrade < 0) {
cout << "Grade must be 0 or greater" << endl;
}
cout << endl;
}
return quizGrade;
}
//gets a single quiz grade value from the user
double getQuizGrade() {
cout << "Please enter the grade for your quiz:" << endl;
double quizGrade = -1;
while (quizGrade < 0) {
quizGrade = iv.getDouble();
if (quizGrade < 0) {
cout << "Grade must be 0 or greater" << endl;
}
cout << endl;
}
return quizGrade;
}
//gets a homework grade value from the user
//the parameter is to output which homework
double getHomeworkGrade(int homeworkNum) {
cout << "Please enter the grade for homework " << homeworkNum << endl;
double homeworkGrade = -1;
while (homeworkGrade < 0) {
homeworkGrade = iv.getDouble();
if (homeworkGrade < 0) {
cout << "Grade must be 0 or greater" << endl;
}
cout << endl;
}
return homeworkGrade;
}
//gets a hitt grade from the user
double getHittGrade() {
//we introduce a bug if the grade is 0
cout << "Please enter the grade for your hitt clicker points:" << endl;
double hittGrade = -1;
while (hittGrade < 0) {
hittGrade = iv.getDouble();
if (hittGrade < 0) {
cout << "Grade must be 0 or greater" << endl;
}
cout << endl;
}
return hittGrade;
}
//gets a quiz grade value from the user
//the parameter is to output which exam
double getProgrammingAssignmentGrade(int paNum) {
//we introduce a bug if the grade is 0
cout << "Please enter the grade for programming assignment " << paNum << ":" << endl;
double paGrade = -1;
while (paGrade < 0) {
paGrade = iv.getDouble();
if (paGrade < 0) {
cout << "Grade must be 0 or greater" << endl;
}
cout << endl;
}
return paGrade;
}
//gets a lab grade value from the user
//the parameter is to output wich lab
double getLabGrade(int labNum) {
//we introduce a bug if the grade is 0
cout << "Please enter the grade for your lab number " << labNum << ":" << endl;
double labGrade = -1;
while (labGrade < 0) {
labGrade = iv.getDouble();
if (labGrade < 0) {
cout << "Grade must be 0 or greater" << endl;
}
cout << endl;
}
return labGrade;
}
//gets a web assign grade from the user
//the parameter is to output whcih web assign
double getWebAssignGrade(int waNum) {
//we introduce a bug if the grade is 0
cout << "Please enter the grade for your web assign number " << waNum << ":" << endl;
double waGrade = -1;
while (waGrade < 0) {
waGrade = iv.getDouble();
if (waGrade < 0) {
cout << "Grade must be 0 or greater" << endl;
}
cout << endl;
}
return waGrade;
}
//gets a single web assign grade from the user
double getWebAssignGrade() {
//we introduce a bug if the grade is 0
cout << "Please enter the grade for your web assign:" << endl;
double waGrade = -1;
while (waGrade < 0) {
waGrade = iv.getDouble();
if (waGrade < 0) {
cout << "Grade must be 0 or greater" << endl;
}
cout << endl;
}
return waGrade;
}
//gets a participation grade from the user
double getParticipationGrade() {
//we introduce a bug if the grade is 0
cout << "Please enter the grade for your participation:" << endl;
double participationGrade = -1;
while (participationGrade < 0) {
participationGrade = iv.getDouble();
if (participationGrade < 0) {
cout << "Grade must be 0 or greater" << endl;
}
cout << endl;
}
return participationGrade;
}
//gets a project grade from the user
//the parameter is to output which project
double getProjectGrade(int projectNum) {
//we introduce a bug if the grade is 0
cout << "Please enter the grade for your project grade number " << projectNum << ":" << endl;
double projectGrade = -1;
while (projectGrade < 0) {
projectGrade = iv.getDouble();
if (projectGrade < 0) {
cout << "Grade must be 0 or greater" << endl;
}
cout << endl;
}
return projectGrade;
}
//gets a term project grade from the user
double getTermProject() {
//we introduce a bug if the grade is 0
cout << "Please enter the grade for your term project:" << endl;
double termProjectGrade = -1;
while (termProjectGrade < 0) {
termProjectGrade = iv.getDouble();
if (termProjectGrade < 0) {
cout << "Grade must be 0 or greater" << endl;
}
cout << endl;
}
return termProjectGrade;
}
//prints the specific grades for all of the
//specific courses whose gpa is not < 0
//if it is < 0, it means that the specific grade
//values have not been entered
void printAllGrades() {
if (phy2048.getGpa() > -1) {
phy2048.printAll();
}
if (phy2049.getGpa() > -1) {
phy2049.printAll();
}
if (cot3100.getGpa() > -1) {
cot3100.printAll();
}
if (cop3502.getGpa() > -1) {
cop3502.printAll();
}
if (cop3503.getGpa() > -1) {
cop3503.printAll();
}
if (chm2045.getGpa() > -1) {
chm2045.printAll();
}
if (mac2311.getGpa() > -1) {
mac2311.printAll();
}
if (mac2312.getGpa() > -1) {
mac2312.printAll();
}
if (mac2313.getGpa() > -1) {
mac2313.printAll();
}
if (mas3114.getGpa() > -1) {
mas3114.printAll();
}
}
#pragma endregion
#pragma region addCourses
//The following functions do the same function for each specific course
//1. Initializes the local variable to a new instance
//2. sets the course name
//3. initializes a course class
//4. sets the course name for that class
//5. gets a credit hours value from user
//6. sets this credit hours value to both the speific course and the general course value
//7. adds the general course to the course manager (cm) to represent it in its list of courses
//does the above for phy2048
void addPHY2048() {
phy2048 = *new Phy2048();
phy2048.setCourseName("PHY2048");
Course course;
course.setCourseName("PHY2048");
int creditHours = getCreditHours();
phy2048.setCredits(creditHours);
course.setCredits(creditHours);
cm.addCourse(course);
}
//does the above for phy2049
void addPHY2049() {
phy2049 = *new Phy2049();
phy2049.setCourseName("PHY2049");
Course course;
course.setCourseName("PHY2049");
int creditHours = getCreditHours();
phy2049.setCredits(creditHours);
course.setCredits(creditHours);
cm.addCourse(course);
}
//does the above for cot3100
void addCOT3100() {
cot3100 = *new Cot3100();
cot3100.setCourseName("COT3100");
Course course;
course.setCourseName("COT3100");
int creditHours = getCreditHours();
cot3100.setCredits(creditHours);
course.setCredits(creditHours);
cm.addCourse(course);
}
//does the above for cop3502
void addCOP3502() {
cop3502 = *new COP3502();
cop3502.setCourseName("COP3502");
Course course;
course.setCourseName("COP3502");
int creditHours = getCreditHours();
cop3502.setCredits(creditHours);
course.setCredits(creditHours);
cm.addCourse(course);
}
//does the above for cop3503
void addCOP3503() {
cop3503 = *new COP3503();
cop3503.setCourseName("COP3503");
Course course;
course.setCourseName("COP3503");
int creditHours = getCreditHours();
cop3503.setCredits(creditHours);
course.setCredits(creditHours);
cm.addCourse(course);
}
//does the above for chm2045
void addCHM2045() {
chm2045.setCourseName("CHM2045");
Course course;
course.setCourseName("CHM2045");
int creditHours = getCreditHours();
chm2045.setCredits(creditHours);
course.setCredits(creditHours);
cm.addCourse(course);
}
//does the above for mac2311
void addMAC2311() {
mac2311 = *new MAC2311();
mac2311.setCourseName("MAC2311");
Course course;
course.setCourseName("MAC2311");
int creditHours = getCreditHours();
mac2311.setCredits(creditHours);
course.setCredits(creditHours);
cm.addCourse(course);
}
//does the above for mac2312
void addMAC2312() {
mac2312 = *new MAC2312();
mac2312.setCourseName("MAC2312");
Course course;
course.setCourseName("MAC2312");
int creditHours = getCreditHours();
mac2312.setCredits(creditHours);
course.setCredits(creditHours);
cm.addCourse(course);
}
//does the above for mac2313
void addMAC2313() {
mac2313 = *new MAC2313();
mac2313.setCourseName("MAC2313");
Course course;
course.setCourseName("MAC2313");
int creditHours = getCreditHours();
mac2313.setCredits(creditHours);
course.setCredits(creditHours);
cm.addCourse(course);
}
//does the above for mas3114
void addMAS3114() {
mas3114 = *new MAS3114();
mas3114.setCourseName("MAS3114");
Course course;
course.setCourseName("MAS3114");
int creditHours = getCreditHours();
mas3114.setCredits(creditHours);
course.setCredits(creditHours);
cm.addCourse(course);
}
//adds a custom course value to cm
void addCustomCourse() {
//declares a new course
Course customCourse;
//makes sure that the user doesn't enter any of these values for the custom course
string courseName = getCourseName();
if (courseName.compare("PHY2048") == 0 || courseName.compare("PHY2049") == 0 || courseName.compare("COT3100") == 0
|| courseName.compare("COP3502") == 0 || courseName.compare("COP3503") == 0 || courseName.compare("CHM2045") == 0
|| courseName.compare("MAC2311") == 0 || courseName.compare("MAC2312") == 0 || courseName.compare("MAC2313") == 0
|| courseName.compare("MAS3114") == 0) {
cout << "Cannot add a course with that name" << endl << endl;
return;
}
//gets the course name, gpa, and credits from the user
customCourse.setCourseName(courseName);
customCourse.setGpa(getGPA());
customCourse.setCredits(getCreditHours());
//adds the course to the course manager
cm.addCourse(customCourse);
}
#pragma endregion
#pragma region editCourses
//the following functions edit the specific grade values for the specific classes
//it calls the .calcGpa() function on the class to crunch the gpa for that class
//this value is stored privately in the class
//lastly, it updates the course representation in the course manager
//does the above for phy2048
void editPHY2048() {
//finals
phy2048.updateFinal(getFinalGrade());
//exams
for (int i = 0; i < 2; i++) {
phy2048.updateExam(i, getExamGrade(i + 1));
}
//quizes
for (int i = 0; i < 10; i++) {
phy2048.updateQuiz(i, getQuizGrade(i + 1));
}
//homework
for (int i = 0; i < 13; i++) {
phy2048.updateHomework(i, getHomeworkGrade(i + 1));
}
//hitt
phy2048.updateHittPoints(getHittGrade());
//calc gpa and updates course manager
phy2048.calcGpa();
Course* course = cm.search(phy2048.getCourseName());
course->setGpa(phy2048.getGpa());
}
//does the above for phy2049
void editPHY2049() {
//finals
phy2049.updateFinal(getFinalGrade());
//exams
for (int i = 0; i < 2; i++) {
phy2049.updateExam(i, getExamGrade(i + 1));
}
//quizes
for (int i = 0; i < 10; i++) {
phy2049.updateQuiz(i, getQuizGrade(i + 1));
}
//homework
for (int i = 0; i < 13; i++) {
phy2049.updateHomework(i, getHomeworkGrade(i + 1));
}
//hitt
phy2049.updateHittPoints(getHittGrade());
//calc gpa and updates course manager
phy2049.calcGpa();
Course* course = cm.search(phy2049.getCourseName());
course->setGpa(phy2049.getGpa());
}
//does the above for cot3100
void editCOT3100() {
//finals
cot3100.updateFinal(getFinalGrade());
//exams
for (int i = 0; i < 4; i++) {
cot3100.updateExam(i, getExamGrade(i + 1));
}
//calc gpa and updates course manager
cot3100.calcGpa();
Course* course = cm.search(cot3100.getCourseName());
course->setGpa(cot3100.getGpa());
}
//does the above for cop3502
void editCOP3502() {
//finals
cop3502.updateFinal(getFinalGrade());
//exams
for (int i = 0; i < 2; i++) {
cop3502.updateExam(i, getExamGrade(i + 1));
}
//homework
for (int i = 0; i < 10; i++) {
cop3502.updateHomework(i, getHomeworkGrade(i + 1));
}
//programming assignments
for (int i = 0; i < 3; i++) {
cop3502.updateProgAssignments(i, getProgrammingAssignmentGrade(i + 1));
}
//labs
for (int i = 0; i < 10; i++) {
cop3502.updateLab(i, getLabGrade(i + 1));
}
//calc gpa and updates course manager
cop3502.calcGpa();
Course* course = cm.search(cop3502.getCourseName());
course->setGpa(cop3502.getGpa());
}
//does the above for cop3503
void editCOP3503() {
//exams
for (int i = 0; i < 2; i++) {
cop3503.updateExams(i, getExamGrade(i + 1));
}
//programming assignments
for (int i = 0; i < 3; i++) {
cop3503.updateAssignments(i, getProgrammingAssignmentGrade(i + 1));
}
//term project
cop3503.updateGroupProject(getTermProject());
//calc gpa and updates course manager
cop3503.calcGpa();
Course* course = cm.search(cop3503.getCourseName());
course->setGpa(cop3503.getGpa());
}
//does the above for chm2045
void editCHM2045() {
//finals
chm2045.updateFinal(getFinalGrade());
//exams
for (int i = 0; i < 3; i++) {
chm2045.updateExam(i, getExamGrade(i + 1));
}
//homework
for (int i = 0; i < 10; i++) {
chm2045.updateHomework(i, getHomeworkGrade(i + 1));
}
//hitt
chm2045.updateHittPoints(getHittGrade());
//calc gpa and updates course manager
chm2045.calcGpa();
Course* course = cm.search(chm2045.getCourseName());
course->setGpa(chm2045.getGpa());
}
//does the above for mac 2311
void editMAC2311() {
//finals
mac2311.updateFinal(getFinalGrade());
//exams
for (int i = 0; i < 3; i++) {
mac2311.updateExam(i, getExamGrade(i + 1));
}
//quizes
for (int i = 0; i < 10; i++) {
mac2311.updateQuiz(i, getQuizGrade(i + 1));
}
//written homework
for (int i = 0; i < 5; i++) {
mac2311.updateWrittenHomework(i, getHomeworkGrade(i + 1));
}
//hitt
mac2311.updateHittPoints(getHittGrade());
//webassign
for (int i = 0; i < 13; i++) {
mac2311.updateWebAssign(i, getWebAssignGrade(i + 1));
}
//calc gpa and updates course manager
mac2311.calcGpa();
Course* course = cm.search(mac2311.getCourseName());
course->setGpa(mac2311.getGpa());
}
//does the above for mac2312
void editMAC2312() {
//finals
mac2312.updateFinal(getFinalGrade());
//exams
for (int i = 0; i < 3; i++) {
mac2312.updateExam(i, getExamGrade(i + 1));
}
//quizes
for (int i = 0; i < 8; i++) {
mac2312.updateQuiz(i, getQuizGrade(i + 1));
}
//written homework
for (int i = 0; i < 3; i++) {
mac2312.updateWrittenHomework(i, getHomeworkGrade(i + 1));
}
//hitt
mac2312.updateHittPoints(getHittGrade());
//webassign
mac2312.updateWebAssign(getWebAssignGrade());
//participation
mac2312.updateParticipation(getParticipationGrade());
//calc gpa and updates course manager
mac2312.calcGpa();
Course* course = cm.search(mac2312.getCourseName());
course->setGpa(mac2312.getGpa());
}
//does the above for mac2313
void editMAC2313() {
//finals
mac2313.updateFinal(getFinalGrade());
//exams
for (int i = 0; i < 3; i++) {
mac2313.updateExam(i, getExamGrade(i + 1));
}
//quizzes
for (int i = 0; i < 13; i++) {
mac2313.updateQuiz(i, getQuizGrade(i + 1));
}
//web assign
for (int i = 0; i < 27; i++) {
mac2313.updateWebAssign(i, getWebAssignGrade(i + 1));
}
//participation
mac2313.updateParticipation(getParticipationGrade());
//calc gpa and updates course manager
mac2313.calcGpa();
Course* course = cm.search(mac2313.getCourseName());
course->setGpa(mac2313.getGpa());
}
//does the above for mas3114
void editMAS3114() {
//exams
for (int i = 0; i < 4; i++) {
mas3114.updateExams(i, getExamGrade(i + 1));
}
//quiz
mas3114.updateQuiz(getQuizGrade());
//homework
for (int i = 0; i < 30; i++) {
mas3114.updateHomework(i, getHomeworkGrade(i + 1));
}
//projects
for (int i = 0; i < 5; i++) {
mas3114.updateProjects(i, getProjectGrade(i + 1));
}
//participation
mas3114.updateParticipation(getParticipationGrade());
//calc gpa and updates course manager
mas3114.calcGpa();
Course* course = cm.search(mas3114.getCourseName());
course->setGpa(mas3114.getGpa());
}
//when given a course pointer, it updates the gpa and credits for it
void editCustomCourse(Course* course) {
course->setGpa(getGPA());
course->setCredits(getCreditHours());
}
#pragma endregion
#pragma endregion
#pragma region menu functions
//menu function helper for add previous gpa functionality
//because of the way gpa is calculated, we can represent all of the previous credit hours earned and
//the gpa by making a course with these values
//when overall gpa is crunched, cm will take this as a normal course, but overall gpa is unaffected
void addPreviousGPA() {
//creates a new course value
Course previousGPA;
//sets the name to previous gpa
previousGPA.setCourseName("Previous GPA");
//sets the gpa value
previousGPA.setGpa(getGPA());
//sets the credit value
previousGPA.setCredits(getCreditHours());
//deletes any previous gpa course value
cm.deleteCourse("Previous GPA");
//adds the new course value
cm.addCourse(previousGPA);
}
//menu helper function for show gpa
void showGPA() {
//print no courses entered when there are no courses
if (cm.empty()) {
cout << "There are no courses entered" << endl;
}
else {
//prints all of the courses when there are some
cm.printCourses();
}
cout << endl;
}
//menu helper function for printing the individual course values
void printCourses() {
//prints no course entered if there are no courses in cm
if (cm.empty()) {
cout << "There are no courses entered" << endl;
}
else {
//calls the print all grades function which prints the individual grades for each of the special functions
printAllGrades();
//calls the print course function of every representative course
cm.printCourses();
}
cout << endl;
}
//menu helper function for adding a course
void addCourse() {
int inputCourse = -1;
//prints the menu
do {
cout << "Please choose from the following courses:" << endl;
cout << "1. PHY2048" << endl << "2. PHY2049" << endl << "3. COT3100" << endl
<< "4. COP3502" << endl << "5. COP3503" << endl << "6. CHM2045" << endl << "7. MAC2311" << endl << "8. MAC2312" << endl
<< "9. MAC2313" << endl << "10. MAS3114" << endl << "11. Custom Course" << endl << "12. Return to main menu" << endl << endl;
//gets int from user
inputCourse = iv.getInt();
//does checks to make sure that the number is valid
if (inputCourse > 12) {
cout << "Invalid choice: " << inputCourse << endl;
}
//if it is 12 we break
if (inputCourse == 12) {
break;
}
cout << endl;
} while (inputCourse < 0 || inputCourse > 12);
//calls the add function for the course selected
switch (inputCourse) {
case 1:
addPHY2048();
break;
case 2:
addPHY2049();
break;
case 3:
addCOT3100();
break;
case 4:
addCOP3502();
break;
case 5:
addCOP3503();
break;
case 6:
addCHM2045();
break;
case 7:
addMAC2311();
break;
case 8:
addMAC2312();
break;
case 9:
addMAC2313();
break;
case 10:
addMAS3114();
break;
case 11:
addCustomCourse();
break;
}
}
//menu helper function for editing a course
void editCourse() {
//prints that there are no courses if cm is empty
if (cm.empty()) {
cout << "There are no courses to edit" << endl << endl;
return;
}
//prompts the user
cout << "Please enter the number of the course to edit:" << endl;
cm.printCourses();
cout << endl;
int choice = -1;
Course* course;
//makes sure that the input is valid
while (choice < 1) {
choice = iv.getInt();
//tries to find the course at that index
course = cm.findAt(choice - 1);
//if it returns a course with an empty string then, no such course was found
if (course->getCourseName().compare("") == 0) {
cout << "Invalid input" << endl;
choice = -1;
}
cout << endl;
}
//calls the appropriate edit function based off of the user input
if (course->getCourseName().compare("PHY2048") == 0) {
editPHY2048();
}
else if (course->getCourseName().compare("PHY2049") == 0) {
editPHY2049();
}
else if (course->getCourseName().compare("COT3100") == 0) {
editCOT3100();
}
else if (course->getCourseName().compare("COP3502") == 0) {
editCOP3502();
}
else if (course->getCourseName().compare("COP3503") == 0) {
editCOP3503();
}
else if (course->getCourseName().compare("CHM2045") == 0) {
editCHM2045();
}
else if (course->getCourseName().compare("MAC2311") == 0) {
editMAC2311();
}
else if (course->getCourseName().compare("MAC2312") == 0) {
editMAC2312();
}
else if (course->getCourseName().compare("MAC2313") == 0) {
editMAC2313();
}
else if (course->getCourseName().compare("MAS3114") == 0) {
editMAS3114();
}
else {
editCustomCourse(course);
}
}
//menu helper function for delete course
void deleteCourse() {
//prints that there are no courses if cm is empty
if (cm.empty()) {
cout << "There are no courses to delete" << endl;
return;
}
//prompts the user
cout << "Please choose from the following courses:" << endl;
cm.printCourses();
cout << endl;
int choice = -1;
Course* course;
while (choice < 1) {
choice = iv.getInt();
//tries to find the course at the given index
course = cm.findAt(choice - 1);
//if cm returns a course with an empty string then there was no course found
if (course->getCourseName().compare("") == 0) {
cout << "Invalid input" << endl;
choice = -1;
}
}
cout << endl;
//wipes the values of the specific course if it is chosen
if (course->getCourseName().compare("PHY2048") == 0) {
phy2048 = *new Phy2048();
}
else if (course->getCourseName().compare("PHY2049") == 0) {
phy2049 = *new Phy2049();
}
else if (course->getCourseName().compare("COT3100") == 0) {
cot3100 = *new Cot3100();