From ac0e4ab43c93d4c886a8c33a491b79c858080b3d Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 2 May 2022 21:45:38 +0300 Subject: Autocommit at 02.05.2022 @ 21:45 --- src/EventSystem/Ticket.cpp | 6 ++++++ src/EventSystem/Ticket.h | 1 + 2 files changed, 7 insertions(+) (limited to 'src/EventSystem') diff --git a/src/EventSystem/Ticket.cpp b/src/EventSystem/Ticket.cpp index 70463db..0199654 100644 --- a/src/EventSystem/Ticket.cpp +++ b/src/EventSystem/Ticket.cpp @@ -24,3 +24,9 @@ void Ticket::write(std::ostream& ostr) const { ostr.write((const char*)&row, sizeof(row)); ostr.write((const char*)&seat, sizeof(seat)); } + +int Ticket::compare(const Ticket& other) const { + if (row == other.row) + return (seat > other.seat) - (other.seat < seat); + return (row > other.row) - (other.row < row); +} diff --git a/src/EventSystem/Ticket.h b/src/EventSystem/Ticket.h index dc87a2f..374612b 100644 --- a/src/EventSystem/Ticket.h +++ b/src/EventSystem/Ticket.h @@ -17,6 +17,7 @@ public: void read(std::istream& istr); void write(std::ostream& ostr) const; + int compare(const Ticket& other) const; }; #endif -- cgit v1.3.1-26-gb76a