-
Notifications
You must be signed in to change notification settings - Fork 0
/
Event.cpp
98 lines (78 loc) · 1.65 KB
/
Event.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* @file Event.cpp
* @brief Definitions of certain functions.
*/
#include "Event.h"
using namespace std;
extern map<string, Artist> artistMap;
extern map<string, Venue> venueMap;
Event::Event(std::string iid, Artist iartist, Venue ilocation, std::string idate, std::string itime)
{
id = iid;
artist = iartist;
location = ilocation;
date = idate;
time = itime;
}
Event::Event(crow::json::rvalue readValueJson)
{
updateFromJson(readValueJson);
}
string Event::getId()
{
return id;
}
void Event::setId(string iid)
{
id = iid;
}
Artist Event::getArtist()
{
return artist;
}
void Event::setArtist(Artist iartist)
{
artist = iartist;
}
double Event::getCost()
{
return location.getCost() + artist.getCost();
}
string Event::getDate()
{
return date;
}
string Event::getTime()
{
return time;
}
void Event::setWhen(string idate, string itime)
{
date = idate;
time = itime;
}
Venue Event::getWhere()
{
return location;
}
void Event::setWhere(Venue ilocation)
{
location = ilocation;
}
crow::json::wvalue Event::convertToJson()
{
crow::json::wvalue writeValueJson;
writeValueJson["id"] = id;
writeValueJson["artist"]["name"] = artist.getName();
writeValueJson["venue"]["city"]= location.getCity();
writeValueJson["date"] = date;
writeValueJson["time"] = time;
return writeValueJson;
}
void Event::updateFromJson(crow::json::rvalue readValueJson)
{
setId(readValueJson["id"].s());
setArtist(artistMap.at(readValueJson["artist"]["name"].s()));
setWhere(venueMap.at(readValueJson["venue"]["city"].s()));
setWhen(readValueJson["date"].s(), readValueJson["time"].s());
}