-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCircuit.cc
63 lines (52 loc) · 1.74 KB
/
Circuit.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
56
57
58
59
60
61
62
63
/** @file Circuit.cc
@brief Código de la clase Circuit
*/
#include "Circuit.hh"
Circuit::Circuit() {}
void Circuit::read_tournaments() {
std::cin >> n_tournaments;
std::string name;
int level;
for (int i = 0; i < n_tournaments; ++i) {
std::cin >> name >> level;
Tournament tour(name, level);
tournaments.insert(make_pair(name, tour));
}
}
void Circuit::add_tournament(const Tournament& tour) {
tournaments.insert(make_pair(tour.get_name(), tour));
++n_tournaments;
}
void Circuit::remove_tournament(const std::string& name, Ranking& global_ranking) {
tournaments.find(name) -> second.remove_points(global_ranking);
global_ranking.sort_rank();
tournaments.erase(name);
--n_tournaments;
}
void Circuit::remove_player_tour(const std::string& name) {
std::map<std::string, Tournament>::iterator it = tournaments.begin();
while (it != tournaments.end()) {
it -> second.remove_player(name);
++it;
}
}
void Circuit::start_tour(const std::string& name, Ranking& global_rank) {
tournaments.find(name) -> second.start_tour(global_rank);
}
void Circuit::end_tour(const std::string& name, Ranking& global_rank, const Categories& c) {
tournaments.find(name) -> second.end_tour(c, global_rank);
}
int Circuit::get_n_tournaments() const {
return n_tournaments;
}
void Circuit::print_tournaments(const Categories& c) const {
std::cout << n_tournaments << std::endl;
std::map<std::string, Tournament>::const_iterator it = tournaments.begin();
while (it != tournaments.end()) {
it -> second.print_tournament(c);
++it;
}
}
bool Circuit::exists_tournament(const std::string& name) const {
return tournaments.end() != tournaments.find(name);
}