-
Notifications
You must be signed in to change notification settings - Fork 0
/
Season.cpp
56 lines (46 loc) · 2.06 KB
/
Season.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
#include "Season.h"
unsigned long long int Season::index = 0;
Season::Season(const size_t& number, const std::string& denomination, std::vector<Film>* episodes, const std::string& slogan, const std::string& description) : EpisodeGrouping::EpisodeGrouping(denomination, slogan, description), Classifiable::Classifiable(denomination, slogan, description) {
setIdentificator("SN", ++index);
setNumber(number);
setEpisodes(episodes);
}
std::string Season::getData(void) const { return "<Temporada>\n- Identificador: " + getIdentificator() + "\n- Fecha de creación: " + getRegistrationString(Identifiable::RegistrationIndex::CREATION_LOG, Identifiable::TimeFormat::BRIEF) + "\n- Fecha de modificación: " + getRegistrationString(Identifiable::RegistrationIndex::CHANGE_LOG, Identifiable::TimeFormat::BRIEF); }
std::string Season::toString(void) const { return "<Temporada> " + getIdentificator() + " (" + getRegistrationString(Identifiable::RegistrationIndex::CREATION_LOG) + ')'; }
size_t Season::getNumber(void) const { return number; }
std::vector<Film> Season::getEpisodes(void) const { return episodes; }
bool Season::setNumber(const size_t& number) {
const bool STATUS{ number >= 0 };
if (STATUS) {
this->number = number;
setChangeLog();
}
return STATUS;
}
void Season::setEpisodes(std::vector<Film>* episodes) {
this->episodes.clear();
if (episodes->size() > 0) {
this->episodes = *episodes;
this->episodes.shrink_to_fit();
setChangeLog();
}
}
bool Season::addEpisode(Film* episode) {
for (const Film& value : episodes)
if (episode->getIdentificator().compare(value.getIdentificator()) == 0) return false;
episodes.push_back(*episode);
episodes.shrink_to_fit();
setChangeLog();
return true;
}
bool Season::deleteEpisode(Film* episode) {
for (size_t index = 0; index < episodes.size(); ++index) {
if (episode->getIdentificator().compare(episodes[index].getIdentificator()) == 0) {
episodes.erase(episodes.begin() + index);
episodes.shrink_to_fit();
setChangeLog();
return true;
}
}
return false;
}