-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudentInfo.cpp
38 lines (31 loc) · 1.1 KB
/
StudentInfo.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
#include "StudentInfo.h"
// create studentinfo instance for 'name' and sets init capacity appropriately
StudentInfo_s::StudentInfo(string name_long, string name_short,
uint16_t numSec) {
this->name_long = name_long;
this->name_short = name_short;
// make the student start as having each section ungraded
for (uint16_t i = 0; i < numSec; i++) {
this->grades.push_back(~0);
}
}
// delete all memory associated with the student instance
StudentInfo_s::~StudentInfo(void) {
// Nothing in the struct to dynamically delete yet
}
// returns the long name stored for this student
string StudentInfo_s::getNameLong(void) {
return name_long;
}
// returns the short name stored for this student
string StudentInfo_s::getNameShort(void) {
return name_short;
}
// returns whether the student responsible
uint8_t StudentInfo_s::checkSectionGrade(uint16_t secIndex) {
return this->grades.at(secIndex);
}
// allows specifcation of up to 64 sections
uint8_t StudentInfo_s::setSectionGrade(uint16_t secIndex, uint8_t percentage) {
return (this->grades.at(secIndex) = (percentage <= 100 ? percentage : ~0));
}