Website Summary Files Commits Branches @commit @diff @stats
path: root / src / EventSystem
diff options
context:
space:
mode:
3 files changed, 20 insertions, 1 deletions
-rw-r--r--src/EventSystem/EventSystem.cpp6
-rw-r--r--src/EventSystem/EventSystem.h2
-rw-r--r--src/EventSystem/Ticket.cpp13
diff --git a/src/EventSystem/EventSystem.cpp b/src/EventSystem/EventSystem.cpp
index 0bbd13a..ccf31c5 100644
--- a/src/EventSystem/EventSystem.cpp
+++ b/src/EventSystem/EventSystem.cpp
@@ -54,11 +54,15 @@ StatusCode EventSystem::cancelEvent(const char* name, const Date& date) {
}
StatusCode EventSystem::reserveTicket(const char* name, const Date& date, const char* password, const char* note, unsigned seatRow, unsigned seatColumn) {
+ return reserveTicket(name, date, password, note, Ticket(seatRow, seatColumn));
+}
+
+StatusCode EventSystem::reserveTicket(const char* name, const Date& date, const char* password, const char* note, const Ticket& ticket) {
unsigned ind = indexOfEvent(name, date);
if (ind == events.get_count())
return E_EventDoesNotExist;
- return events[ind].reserveTicket(Ticket(seatRow, seatColumn), password, note);
+ return events[ind].reserveTicket(ticket, password, note);
}
StatusCode EventSystem::cancelTicketReservation(const char* name, const Date& date, unsigned seatRow, unsigned seatColumn) {
diff --git a/src/EventSystem/EventSystem.h b/src/EventSystem/EventSystem.h
index d00b14b..7956b72 100644
--- a/src/EventSystem/EventSystem.h
+++ b/src/EventSystem/EventSystem.h
@@ -23,6 +23,8 @@ public:
StatusCode cancelEvent(const char* name, const Date& date);
StatusCode reserveTicket(const char* name, const Date& date, const char* password, const char* note, unsigned seatRow, unsigned seatColumn);
+ StatusCode reserveTicket(const char* name, const Date& date, const char* password, const char* note, const Ticket& ticket);
+
StatusCode cancelTicketReservation(const char* name, const Date& date, unsigned seatRow, unsigned seatColumn);
StatusCode buyTicket(const char* name, const Date& date, unsigned row, unsigned seat);
StatusCode buyTicket(const char* name, const Date& date, unsigned row, unsigned seat, const char* password);
diff --git a/src/EventSystem/Ticket.cpp b/src/EventSystem/Ticket.cpp
index 0199654..997045e 100644
--- a/src/EventSystem/Ticket.cpp
+++ b/src/EventSystem/Ticket.cpp
@@ -30,3 +30,16 @@ int Ticket::compare(const Ticket& other) const {
return (seat > other.seat) - (other.seat < seat);
return (row > other.row) - (other.row < row);
}
+
+/* General */
+
+std::istream& operator>>(std::istream& istr, Ticket& ticket) {
+ unsigned row, seat;
+ istr >> row >> seat;
+ ticket = Ticket(row, seat);
+ return istr;
+}
+
+std::ostream& operator<<(std::ostream& ostr, const Ticket& ticket) {
+ return ostr << ticket.get_row() << " " << ticket.get_seat();
+}