From 0521180c61e7d8970f164f3154599e49800e85c6 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 2 May 2022 21:40:36 +0300 Subject: Autocommit at 02.05.2022 @ 21:40 --- src/EventSystem/Event.cpp | 4 +++- src/EventSystem/Reservation.cpp | 4 ++++ src/EventSystem/Reservation.h | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) (limited to 'src/EventSystem') diff --git a/src/EventSystem/Event.cpp b/src/EventSystem/Event.cpp index cdbc017..9744e2e 100644 --- a/src/EventSystem/Event.cpp +++ b/src/EventSystem/Event.cpp @@ -10,7 +10,9 @@ Event::Event(const Hall* hall, String name, DateTime time) { } StatusCode Event::reserveTicket(const Ticket& ticket, const char* password, const char* note) { - // TODO: if (reservations.contains(ticket) || tickets.contain(ticket)) return E_... + if (tickets.contain(ticket)) return E_TicketAlreadyBought; + if (reservations.contain(Reservation(ticket, "", ""))) return E_TicketAlreadyReserved; + reservations.insert(Reservation(ticket, password, note)); return Success; } diff --git a/src/EventSystem/Reservation.cpp b/src/EventSystem/Reservation.cpp index ba12547..613a715 100644 --- a/src/EventSystem/Reservation.cpp +++ b/src/EventSystem/Reservation.cpp @@ -21,3 +21,7 @@ void Reservation::write(std::ostream& ostr) const { ostr.write(password, sizeof(password)); ostr.write(note, sizeof(note)); } + +int Reservation::compare(const Reservation& other) const { + return ticket.compare(other.ticket); +} diff --git a/src/EventSystem/Reservation.h b/src/EventSystem/Reservation.h index 7e96412..acc294c 100644 --- a/src/EventSystem/Reservation.h +++ b/src/EventSystem/Reservation.h @@ -16,6 +16,7 @@ public: void read(std::istream& istr); void write(std::ostream& ostr) const; + int compare(const Reservation& other) const; }; #endif -- cgit v1.3.1-26-gb76a