From b844597fd23bc57aa97e231fc90eecfd6322cecc Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 7 May 2022 08:28:27 +0300 Subject: Reorganized whole architecture --- src/Models/Reservation.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/Models/Reservation.cpp (limited to 'src/Models/Reservation.cpp') diff --git a/src/Models/Reservation.cpp b/src/Models/Reservation.cpp new file mode 100644 index 0000000..26278b2 --- /dev/null +++ b/src/Models/Reservation.cpp @@ -0,0 +1,37 @@ +#include "Reservation.h" +#include +#include + +Reservation::Reservation() : Reservation(Ticket(), "", "") {} + +Reservation::Reservation(const Ticket& ticket) : Reservation(ticket, "", "") {} + +Reservation::Reservation(const Ticket& ticket, const char* password, const char* note) { + this->ticket = ticket; + strcpy(this->password, password); + strcpy(this->note, note); +} + +bool Reservation::validPassword(const char* password) const { + return !strcmp(this->password, password); +} + +const Ticket& Reservation::get_ticket() const { + return ticket; +} + +void Reservation::read(std::istream& istr) { + ticket.read(istr); + istr.read(password, sizeof(password)); + istr.read(note, sizeof(note)); +} + +void Reservation::write(std::ostream& ostr) const { + ticket.write(ostr); + ostr.write(password, sizeof(password)); + ostr.write(note, sizeof(note)); +} + +int Reservation::compare(const Reservation& other) const { + return ticket.compare(other.ticket); +} -- cgit v1.3.1-23-gd82d