-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudent.cpp
51 lines (41 loc) · 1.39 KB
/
Student.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
#include <algorithm>
#include "Student.h"
#include "EvaluationChart.h"
Student::Student(const std::string &name) : m_name(name) {}
void Student::add_course(const Course* new_course, double grade) {
m_done_courses_with_grades[new_course] = grade;
auto res = std::find(m_done_courses.begin(), m_done_courses.end(), new_course);
if (res == m_done_courses.end())
m_done_courses.push_back(new_course);
}
void Student::add_evaluation_chart(EvaluationChart new_chart) {
m_done_programs.emplace_back(new_chart);
}
std::string Student::get_name() {
return m_name;
}
int Student::get_next_pres_number(const Program* program) const {
int id = 1;
for (auto chart : m_done_programs) {
if (chart.get_program() == program)
id = std::max(id, chart.get_pres() + 1);
}
return id;
}
double Student::get_grade_of_course(const Course* course) const{
return m_done_courses_with_grades.find(course)->second;
}
std::vector<EvaluationChart> Student::get_charts_by_program(const Program* program) const {
std::vector<EvaluationChart> charts;
for (auto chart : m_done_programs) {
if (chart.get_program() == program)
charts.emplace_back(chart);
}
return charts;
}
std::vector<const Course*> Student::get_done_courses() const {
return m_done_courses;
}
std::vector<EvaluationChart> Student::get_all_charts() {
return m_done_programs;
}