-
Notifications
You must be signed in to change notification settings - Fork 0
/
Grade.cpp
63 lines (49 loc) · 1.42 KB
/
Grade.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
52
53
54
55
56
57
58
59
60
61
//
// Created by Claudio Delgado on 2024-11-11.
//
#include "Grade.h"
#include "Student.h"
#include "Course.h"
#include "GradeCalculationStrategy.h"
Grade::Grade(const std::shared_ptr<Student>& student,
const std::shared_ptr<Course>& course,
const std::string& name,
double score,
GradeType type,
const std::shared_ptr<GradeCalculationStrategy>& strategy)
: GradeComponent(name, score), student(student), course(course), type(type),
calculationStrategy(strategy), totalGrade(0.0) {}
void Grade::setScore(double score) {
this->score = score;
}
double Grade::getScore() const {
return score;
}
void Grade::calculateTotalGrade() {
if (calculationStrategy) {
totalGrade = calculationStrategy->calculateGrade(score);
} else {
totalGrade = score;
}
}
GradeType Grade::getType() const {
return type;
}
void Grade::setType(GradeType type) {
this->type = type;
}
std::shared_ptr<GradeCalculationStrategy> Grade::getCalculationStrategy() const {
return calculationStrategy;
}
void Grade::setCalculationStrategy(const std::shared_ptr<GradeCalculationStrategy>& strategy) {
calculationStrategy = strategy;
}
double Grade::getTotalGrade() const {
return totalGrade;
}
std::shared_ptr<Course> Grade::getCourse() const {
return course;
}
std::shared_ptr<Student> Grade::getStudent() const {
return student;
}