blob: 5bc11f74a827319a23341c176d193a407ab6dfc8 (
plain)
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
|
#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);
}
}
|