-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMarks.cpp
30 lines (25 loc) · 900 Bytes
/
Marks.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
//
// Created by lafayett on 30/01/19.
//
#include <algorithm>
#include <iostream>
#include <iomanip>
#include "Marks.h"
Marks::Marks(const std::unordered_map<std::string, double> &classMarks) :
classMarks(classMarks) {}
double Marks::averageSomeClasses(const std::vector<std::string> &classes) const {
// TODO Write this method
return 0;
}
void Marks::addMark(const std::string &classs, const double mark) {
classMarks[classs] = mark;
}
std::ostream &operator<<(std::ostream &ostr, const Marks &marks) {
ostr << "Classes: " << std::endl;
std::for_each(marks.classMarks.cbegin(), marks.classMarks.cend(),
[&](const std::pair<std::string, double> &entry) {
ostr << "\t" << entry.first << ": " << std::fixed << std::setprecision(2) << entry.second
<< std::endl;
});
return ostr;
}