-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCourse.cc
56 lines (42 loc) · 934 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
44
45
46
47
48
49
50
51
52
53
54
55
#include <iostream>
#include <iomanip>
#include <string>
#include "Course.h"
using namespace std;
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 << " " << 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* other){
if(code < other->code)
return true;
else if(code == other->code)
return term < other->term;
else
return false;
}
int Course::getGrade() {
return grade;
}