diff options
Autocommit at 05.05.2022 @ 20:18
4 files changed, 23 insertions, 6 deletions
| -rw-r--r-- | src/EventSystem/EventSystem.cpp | 6 | ||||
| -rw-r--r-- | src/EventSystem/EventSystem.h | 2 | ||||
| -rw-r--r-- | src/EventSystem/Ticket.cpp | 13 | ||||
| -rw-r--r-- | src/VenueConsoleUI.cpp | 8 |
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(); +} diff --git a/src/VenueConsoleUI.cpp b/src/VenueConsoleUI.cpp index 2799605..c801cfb 100644 --- a/src/VenueConsoleUI.cpp +++ b/src/VenueConsoleUI.cpp @@ -46,12 +46,10 @@ void command_reserveTicket() { inputBox("Enter password [Max 8 characters]: ", &password); char note[NOTE_LEN]; inputBox("Enter note [Max 32 characters]: ", ¬e); - unsigned row; - inputBox("Enter row: ", &row); - unsigned seat; - inputBox("Enter seat: ", &seat); + Ticket tic; + inputBox("Enter row and seat: ", &tic); - handleStatusCode(v->get_es().reserveTicket(name, date, password, note, row, seat), ticketManagementMenu); + handleStatusCode(v->get_es().reserveTicket(name, date, password, note, tic), ticketManagementMenu); } void command_cancelReservation() { |
