#include "People.h" #include "Exception.h" #include "util.h" using namespace std; People::~People() { for (Artist * artist : this->artists) { if (artist == nullptr) continue; delete artist; } this->artists.clear(); } void People::add_artist(ArtistData data) { this->artists.push_back(new Artist(data)); } size_t People::artists_size() { return this->artists.size(); } Artist & People::get_artist(size_t index) { if (index >= this->artists_size()) throw Exception("No artist with index %lu", index); return *this->artists[index]; } string People::to_string() { string out = ""; out += stringf("%d artists\n", this->artists_size()); for (size_t i = 0; i < this->artists_size(); i++) { Artist & artist = this->get_artist(i); out += stringf("[%d] at (%.2f,%.2f)\n", i, artist.data.x, artist.data.y); } return out; } void People::update(Museum & museum) { for (Artist * artist : this->artists) { if (artist == nullptr) continue; artist->update(museum); } }