diff options
Autocommit at 07.05.2022 @ 09:12
4 files changed, 48 insertions, 27 deletions
| -rw-r--r-- | src/Services/EventService.cpp | 38 | ||||
| -rw-r--r-- | src/Services/EventService.h | 16 | ||||
| -rw-r--r-- | src/Services/HallService.cpp | 5 | ||||
| -rw-r--r-- | src/Services/HallService.h | 16 |
diff --git a/src/Services/EventService.cpp b/src/Services/EventService.cpp index 95bd1c4..ec474a9 100644 --- a/src/Services/EventService.cpp +++ b/src/Services/EventService.cpp @@ -1,13 +1,13 @@ -#include "EventSystem.h" +#include "EventService.h" #include "StatusCodes.h" /* Private */ -void EventSystem::updateSoonestUpcoming() { +void EventService::updateSoonestUpcoming() { } -unsigned EventSystem::indexOfEvent(const Date& date) { +unsigned EventService::indexOfEvent(const Date& date) { // TODO: make binary search for (unsigned i = indSoonestUpcoming; i < events.get_count(); i++) { if (events[i].get_date().compare(date) == 0) @@ -16,7 +16,7 @@ unsigned EventSystem::indexOfEvent(const Date& date) { return events.get_count(); } -unsigned EventSystem::indexOfEvent(const char* name, const Date& date) { +unsigned EventService::indexOfEvent(const char* name, const Date& date) { unsigned ind = indexOfEvent(date); if (ind < events.get_count() && events[ind].get_name().compare(name) == 0) return ind; @@ -25,18 +25,18 @@ unsigned EventSystem::indexOfEvent(const char* name, const Date& date) { /* Public */ -EventSystem::EventSystem() { +EventService::EventService() { events = OrderedList<Event>(); indSoonestUpcoming = 0; } -EventSystem::EventSystem(const Event* events, unsigned eventCount) { +EventService::EventService(const Event* events, unsigned eventCount) { this->events = OrderedList<Event>(events, eventCount); indSoonestUpcoming = 0; updateSoonestUpcoming(); } -StatusCode EventSystem::createEvent(const Hall* hall, String name, Date date) { +StatusCode EventService::createEvent(const Hall* hall, String name, Date date) { if (indexOfEvent(date) < events.get_count()) return E_EventWillOverlap; @@ -44,7 +44,7 @@ StatusCode EventSystem::createEvent(const Hall* hall, String name, Date date) { return Success; } -StatusCode EventSystem::cancelEvent(const char* name, const Date& date) { +StatusCode EventService::cancelEvent(const char* name, const Date& date) { unsigned ind = indexOfEvent(name, date); if (ind == events.get_count()) return E_EventDoesNotExist; @@ -53,11 +53,11 @@ StatusCode EventSystem::cancelEvent(const char* name, const Date& date) { return Success; } -StatusCode EventSystem::reserveTicket(const char* name, const Date& date, const char* password, const char* note, unsigned seatRow, unsigned seatColumn) { +StatusCode EventService::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) { +StatusCode EventService::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; @@ -65,11 +65,11 @@ StatusCode EventSystem::reserveTicket(const char* name, const Date& date, const return events[ind].reserveTicket(ticket, password, note); } -StatusCode EventSystem::cancelTicketReservation(const char* name, const Date& date, unsigned seatRow, unsigned seatColumn) { +StatusCode EventService::cancelTicketReservation(const char* name, const Date& date, unsigned seatRow, unsigned seatColumn) { return cancelTicketReservation(name, date, Ticket(seatRow, seatColumn)); } -StatusCode EventSystem::cancelTicketReservation(const char* name, const Date& date, const Ticket& ticket) { +StatusCode EventService::cancelTicketReservation(const char* name, const Date& date, const Ticket& ticket) { unsigned ind = indexOfEvent(name, date); if (ind == events.get_count()) return E_EventDoesNotExist; @@ -77,11 +77,11 @@ StatusCode EventSystem::cancelTicketReservation(const char* name, const Date& da return events[ind].cancelReservation(ticket); } -StatusCode EventSystem::buyTicket(const char* name, const Date& date, unsigned row, unsigned seat) { +StatusCode EventService::buyTicket(const char* name, const Date& date, unsigned row, unsigned seat) { return buyTicket(name, date, Ticket(row, seat)); } -StatusCode EventSystem::buyTicket(const char* name, const Date& date, const Ticket& ticket) { +StatusCode EventService::buyTicket(const char* name, const Date& date, const Ticket& ticket) { unsigned ind = indexOfEvent(name, date); if (ind == events.get_count()) return E_EventDoesNotExist; @@ -89,11 +89,11 @@ StatusCode EventSystem::buyTicket(const char* name, const Date& date, const Tick return events[ind].buyTicket(ticket); } -StatusCode EventSystem::buyTicket(const char* name, const Date& date, unsigned row, unsigned seat, const char* password) { +StatusCode EventService::buyTicket(const char* name, const Date& date, unsigned row, unsigned seat, const char* password) { return buyTicket(name, date, Ticket(row, seat), password); } -StatusCode EventSystem::buyTicket(const char* name, const Date& date, const Ticket& ticket, const char* password) { +StatusCode EventService::buyTicket(const char* name, const Date& date, const Ticket& ticket, const char* password) { unsigned ind = indexOfEvent(name, date); if (ind == events.get_count()) return E_EventDoesNotExist; @@ -102,7 +102,7 @@ StatusCode EventSystem::buyTicket(const char* name, const Date& date, const Tick } -const Hall* EventSystem::queryEventHall(const char* name, const Date& date) { +const Hall* EventService::queryEventHall(const char* name, const Date& date) { unsigned ind = indexOfEvent(name, date); if (ind == events.get_count()) return nullptr; @@ -110,7 +110,7 @@ const Hall* EventSystem::queryEventHall(const char* name, const Date& date) { return &events[ind].get_hall(); } -OrderedList<Ticket> EventSystem::queryTickets(const char* name, const Date& date) { +OrderedList<Ticket> EventService::queryTickets(const char* name, const Date& date) { unsigned ind = indexOfEvent(name, date); if (ind == events.get_count()) return OrderedList<Ticket>(); @@ -118,7 +118,7 @@ OrderedList<Ticket> EventSystem::queryTickets(const char* name, const Date& date return events[ind].get_tickets(); } -OrderedList<Reservation> EventSystem::queryReservations(const char* name, const Date& date) { +OrderedList<Reservation> EventService::queryReservations(const char* name, const Date& date) { unsigned ind = indexOfEvent(name, date); if (ind == events.get_count()) return OrderedList<Reservation>(); diff --git a/src/Services/EventService.h b/src/Services/EventService.h index 4eeac61..125e056 100644 --- a/src/Services/EventService.h +++ b/src/Services/EventService.h @@ -1,13 +1,13 @@ -#ifndef HEADER_EVENTSYSTEM -#define HEADER_EVENTSYSTEM +#ifndef HEADER_SERVICE_EVENTSERVICE +#define HEADER_SERVICE_EVENTSERVICE -#include "../List/OrderedList.hpp" -#include "../Date/Date.h" +#include "../Generic/List/OrderedList.hpp" +#include "../Generic/Date/Date.h" -#include "Event.h" +#include "../Models/Event.h" #include "StatusCodes.h" -class EventSystem { +class EventService { OrderedList<Event> events; unsigned indSoonestUpcoming; @@ -16,8 +16,8 @@ class EventSystem { unsigned indexOfEvent(const char* name, const Date& date); public: - EventSystem(); - EventSystem(const Event* events, unsigned eventCount); + EventService(); + EventService(const Event* events, unsigned eventCount); StatusCode createEvent(const Hall* hall, String name, Date date); StatusCode cancelEvent(const char* name, const Date& date); diff --git a/src/Services/HallService.cpp b/src/Services/HallService.cpp new file mode 100644 index 0000000..0bc8a22 --- /dev/null +++ b/src/Services/HallService.cpp @@ -0,0 +1,5 @@ +#include "HallService.h" + +HallService::HallService(const Hall* halls, unsigned hallCount) { + this->halls = OrderedList<Hall>(halls, hallCount); +} diff --git a/src/Services/HallService.h b/src/Services/HallService.h new file mode 100644 index 0000000..88df0a3 --- /dev/null +++ b/src/Services/HallService.h @@ -0,0 +1,16 @@ +#ifndef HEADER_SERVICE_HALLSERVICE +#define HEADER_SERVICE_HALLSERVICE + +#include "../Generic/List/OrderedList.hpp" +#include "../Models/Hall.h" + +class HallService { + OrderedList<Hall> halls; + +public: + HallService(const Hall* halls, unsigned hallCount); + + bool hallExists(); +}; + +#endif |
