Website Summary Files Commits Branches @commit @diff @stats
path: root / src / EventSystem
diff options
context:
space:
mode:
Commit0521180c61e7d8970f164f3154599e49800e85c6 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-02 21:40:36 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-02 21:40:36 +0300
Files33d4af5bcc2acc4fdde00401ae522365c19c17de /src/EventSystem
FMI-OOP-P1_TicketSystem-0521180c61e7d8970f164f3154599e49800e85c6.tar
FMI-OOP-P1_TicketSystem-0521180c61e7d8970f164f3154599e49800e85c6.tar.gz
FMI-OOP-P1_TicketSystem-0521180c61e7d8970f164f3154599e49800e85c6.zip
Parent26d3ecce1211b58dbe79302844395c550340d946 (diff)
Autocommit at 02.05.2022 @ 21:40
3 files changed, 8 insertions, 1 deletions
-rw-r--r--src/EventSystem/Event.cpp4
-rw-r--r--src/EventSystem/Reservation.cpp4
-rw-r--r--src/EventSystem/Reservation.h1
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