-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCourse.cc
43 lines (35 loc) · 857 Bytes
/
Course.cc
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
#include "Course.h"
#include <iostream>
#include <iomanip>
Course::Course(int c, int g, int t, string i) : code(c), grade(g), term(t), instructor(i)
{
}
void Course::print()
{
string str;
cout << "-- COMP " << code << ": ";
cout << right << setw(6) << term << " ";
cout << right << setw(2) << grade << " ";
getGradeStr(str);
cout << left << setw(3) << str << " ";
cout << instructor << " " << endl;
}
void Course::getGradeStr(string& gradeStr)
{
string gradeStrings[] = {
"WDN", "F", "D-", "D", "D+", "C-", "C", "C+",
"B-", "B", "B+", "A-", "A", "A+" };
if ( grade >= -1 && grade <= 12 )
gradeStr = gradeStrings[grade+1];
else
gradeStr = "Unknown";
}
bool Course::lessThan(Course* c)
{
if (code == c->code)
return term < c->term;
return code < c->code;
}
int Course::getGrade() {
return grade;
}