Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Services / EventService.cpp
diff options
context:
space:
mode:
Commit451c2832197964b0d5ba225304e1361440d454af (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-07 12:18:03 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-07 12:18:03 +0300
Files3c811f3eba676d4025fa58b872317465775928b5 /src/Services/EventService.cpp
FMI-OOP-P1_TicketSystem-451c2832197964b0d5ba225304e1361440d454af.tar
FMI-OOP-P1_TicketSystem-451c2832197964b0d5ba225304e1361440d454af.tar.gz
FMI-OOP-P1_TicketSystem-451c2832197964b0d5ba225304e1361440d454af.zip
Parent4da4dc9f7658a25eb90647a49514680976d5c382 (diff)
Autocommit at 07.05.2022 @ 12:18
1 files changed, 8 insertions, 9 deletions
-rw-r--r--src/Services/EventService.cpp17
diff --git a/src/Services/EventService.cpp b/src/Services/EventService.cpp
index ac3129d..ece9774 100644
--- a/src/Services/EventService.cpp
+++ b/src/Services/EventService.cpp
@@ -135,29 +135,28 @@ StatusCode EventService::buyTicket(const char* name, const Date& date, const Tic
return Success;
}
-void EventService::createSeatingString(const char* name, const Date& date, unsigned* seatsPerRow, char** out) {
- delete[] *out;
-
+String EventService::createSeatingString(const char* name, const Date& date, unsigned* seatsPerRow) {
unsigned eInd = indexOfEvent(name, date);
if (eInd == events.get_count()) {
- return;
+ return "";
}
unsigned rowCount = events[eInd].get_hall().get_rows(), seatsCount = events[eInd].get_hall().get_seatsPerRow();
*seatsPerRow = seatsCount;
- *out = new char[rowCount * seatsCount + 1];
+ String out = new char[rowCount * seatsCount + 1];
for (unsigned acc = 0, row = 1; row <= rowCount; row++) {
for (unsigned seat = 1; seat <= seatsCount; seat++, acc++) {
if (events[eInd].get_tickets().contain(Ticket(row, seat)))
- *out[acc] = 'B';
+ out[acc] = 'B';
else if (events[eInd].get_reservations().contain(Ticket(row, seat)))
- *out[acc] = 'R';
+ out[acc] = 'R';
else
- *out[acc] = ' ';
+ out[acc] = ' ';
}
}
- *out[seatsCount * rowCount] = '\0';
+ out[seatsCount * rowCount] = '\0';
+ return out;
}