diff options
Diffstat (limited to 'People.cpp')
-rw-r--r-- | People.cpp | 22 |
1 files changed, 7 insertions, 15 deletions
@@ -1,7 +1,6 @@ #include <algorithm> #include "People.h" -#include "Exception.h" #include "util.h" using namespace std; @@ -16,8 +15,8 @@ People::~People() { this->artists.clear(); } -void People::add_artist(ArtistData data) { - if (this->artists.size() > 30e3) return; +void People::add_artist(const ArtistData & data) { + if (this->artists.size() >= 30e3) return; this->artists.push_back(new Artist(this->museum, data)); } @@ -27,23 +26,16 @@ void People::remove_artist(Artist & target) { this->artists.erase(it); } -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]; +list<Artist *> People::get_artists() { + return this->artists; } 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); + 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; |