Website Summary Files Commits Branches @commit @diff @stats
path: root / src
diff options
context:
space:
mode:
Commite79951e129ae4f0f6f51496c247edabce0c1d0c5 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-07 10:57:41 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-07 10:57:41 +0300
Filese37d73e4a05c5e2d403c0bc39de2e2057a129973 /src
FMI-OOP-P1_TicketSystem-e79951e129ae4f0f6f51496c247edabce0c1d0c5.tar
FMI-OOP-P1_TicketSystem-e79951e129ae4f0f6f51496c247edabce0c1d0c5.tar.gz
FMI-OOP-P1_TicketSystem-e79951e129ae4f0f6f51496c247edabce0c1d0c5.zip
Parent58a0aded601479d7d1ba8a256e500e95f2bcb5bc (diff)
Autocommit at 07.05.2022 @ 10:57
5 files changed, 22 insertions, 6 deletions
-rw-r--r--src/Generic/String/String.cpp8
-rw-r--r--src/Generic/String/String.h2
-rw-r--r--src/Services/EventService.cpp4
-rw-r--r--src/Services/EventService.h2
-rw-r--r--src/UserInterface/VenueConsoleUI.cpp12
diff --git a/src/Generic/String/String.cpp b/src/Generic/String/String.cpp
index 99c2e0c..f327795 100644
--- a/src/Generic/String/String.cpp
+++ b/src/Generic/String/String.cpp
@@ -34,6 +34,14 @@ const char* String::get_cstr() const {
return str;
}
+unsigned String::get_count() const {
+ return count;
+}
+
+unsigned String::get_length() const {
+ return length;
+}
+
String& String::operator+=(const String& other) {
char* newStr = new char[length + other.length + 1];
strncpy(newStr, str, length);
diff --git a/src/Generic/String/String.h b/src/Generic/String/String.h
index cefb05d..3383fe9 100644
--- a/src/Generic/String/String.h
+++ b/src/Generic/String/String.h
@@ -13,6 +13,8 @@ class String {
public:
String(const char* str);
const char* get_cstr() const;
+ unsigned get_count() const;
+ unsigned get_length() const;
String& operator+=(const String& other);
String& operator+=(char character);
diff --git a/src/Services/EventService.cpp b/src/Services/EventService.cpp
index fc62c64..a1ba34e 100644
--- a/src/Services/EventService.cpp
+++ b/src/Services/EventService.cpp
@@ -135,12 +135,14 @@ StatusCode EventService::buyTicket(const char* name, const Date& date, const Tic
return Success;
}
-String EventService::createSeatingString(const char* name, const Date& date) {
+String EventService::createSeatingString(const char* name, const Date& date, unsigned* seatsPerRow) {
unsigned eInd = indexOfEvent(name, date);
if (eInd == events.get_count())
return "";
unsigned rowCount = events[eInd].get_hall().get_rows(), seatsCount = events[eInd].get_hall().get_seatsPerRow();
+ *seatsPerRow = seatsCount;
+
String out;
for (unsigned row = 1; row <= rowCount; row++) {
for (unsigned seat = 1; seat <= seatsCount; seat++) {
diff --git a/src/Services/EventService.h b/src/Services/EventService.h
index 6e7b970..214d6ff 100644
--- a/src/Services/EventService.h
+++ b/src/Services/EventService.h
@@ -34,7 +34,7 @@ public:
StatusCode buyTicket(const char* name, const Date& date, unsigned row, unsigned seat);
StatusCode buyTicket(const char* name, const Date& date, const Ticket& ticket);
- String createSeatingString(const char* name, const Date& date);
+ String createSeatingString(const char* name, const Date& date, unsigned* seatsPerRow = nullptr);
void queryMostVisited();
void queryInsufficientlyVisited();
diff --git a/src/UserInterface/VenueConsoleUI.cpp b/src/UserInterface/VenueConsoleUI.cpp
index 04ad0a5..86cae18 100644
--- a/src/UserInterface/VenueConsoleUI.cpp
+++ b/src/UserInterface/VenueConsoleUI.cpp
@@ -44,10 +44,14 @@ void command_freeSeats() {
Date date;
inputSubBox("Enter event date: ", &date);
- String seating = es->createSeatingString(name, date);
+ unsigned seatsPerRow = 0;
+ String seating = es->createSeatingString(name, date, &seatsPerRow);
+ if (seating.get_count() == 0) {
+ handleStatusCode(E_EventDoesNotExist, ticketManagementMenu);
+ return;
+ }
- tableData[tableSize] = '\0';
- table(1, hall->get_seatsPerRow(), tableData);
+ table(1, seatsPerRow, seating.get_cstr());
char tmp;
inputLineBox("[Press enter to continue]", &tmp, 1);
@@ -63,7 +67,7 @@ void command_reserveTicket() {
char password[PASSWORD_LEN];
inputSubBox("Enter password [Max 8 characters]: ", &password);
char note[NOTE_LEN];
- inputSubBox("Enter note [Max 32 characters]: ", &note);
+ inputLineSubBox("Enter note [Max 32 characters]: ", &note, NOTE_LEN);
StatusCode s = es->reserveTicket(name, date, password, note, tic);
handleStatusCode(s, ticketManagementMenu);