blob: d86b907cc894ad80a564f0b5437cc0cbffffc408 (
plain) (
blame)
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
|
#include "Event.h"
#include "Reservation.h"
Event::Event() : hall(), name(), date() {}
Event::Event(const Hall& hall, String name, Date date) : tickets(), reservations() {
this->hall = &hall;
this->name = name;
this->date = date;
}
OrderedList<Ticket>& Event::get_tickets() {
return tickets;
}
OrderedList<Reservation>& Event::get_reservations() {
return reservations;
}
const Hall& Event::get_hall() const {
return *hall;
}
const String& Event::get_name() const {
return name;
}
const Date& Event::get_date() const {
return date;
}
void Event::print(std::ostream& ostr) {
ostr.write(hall, sizeof(hall));
}
void Event::write(std::istream& istr);
int Event::compare(const Event& other) {
if (hall == other.hall)
return date.compare(other.date);
return hall->compare(*other.hall);
}
std::istream& operator>>(std::istream& istr, Event& event) {
return istr >> event.hall >> event.name >> event.date >> event.tickets >> event.reservations;
}
std::ostream& operator<<(std::ostream& ostr, const Event& event) {
ostr << "Hall: " << event.hall << " Name: " << event.name << " Date: " << event.date << std::endl;
ostr << "Bought tickets: ";
for (unsigned i = 0; i < event.tickets.get_count(); i++)
ostr << event.tickets[i] << " ";
ostr << std::endl << "Reserved tickets: ";
for (unsigned i = 0; i < event.reservations.get_count(); i++)
ostr << event.reservations[i] << " ";
return ostr << std::endl;
}
|