#include #include "People.h" #include "util.h" using namespace std; People::People(Museum & museum) : museum(museum) {} People::~People() { for (Artist * artist : this->artists) { if (artist == nullptr) continue; delete artist; } this->artists.clear(); } void People::add_artist(const ArtistData & data) { if (this->artists.size() >= 30e3) return; this->artists.push_back(new Artist(this->museum, data)); } void People::remove_artist(Artist & target) { auto it = find(this->artists.begin(), this->artists.end(), &target); if (it == this->artists.end()) return; this->artists.erase(it); } list People::get_artists() { return this->artists; } string People::to_string() { string out = ""; out += stringf("%d artists\n", this->artists.size()); for (Artist * artist : this->artists) { out += stringf("- at (%.2f,%.2f)\n", artist->data.x, artist->data.y); } return out; } void People::update() { for (Artist * artist : this->artists) { if (artist == nullptr) continue; artist->update(); } }