Website Summary Files Commits Branches @commit @diff @stats
path: root / src / ConsoleInterface
diff options
context:
space:
mode:
Commitcd07f3c013b8cbf467cd1ebca9da19f2bcdfa50b (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-05 18:03:38 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-05 18:03:38 +0300
Filescf789524fda892718597981fe8e6f4446fbdc798 /src/ConsoleInterface
FMI-OOP-P1_TicketSystem-cd07f3c013b8cbf467cd1ebca9da19f2bcdfa50b.tar
FMI-OOP-P1_TicketSystem-cd07f3c013b8cbf467cd1ebca9da19f2bcdfa50b.tar.gz
FMI-OOP-P1_TicketSystem-cd07f3c013b8cbf467cd1ebca9da19f2bcdfa50b.zip
Parent7c157cdade0548127937e9b32468b8d3ff9a42bb (diff)
Autocommit at 05.05.2022 @ 18:03
2 files changed, 10 insertions, 2 deletions
-rw-r--r--src/ConsoleInterface/Menu.cpp11
-rw-r--r--src/ConsoleInterface/Menu.h1
diff --git a/src/ConsoleInterface/Menu.cpp b/src/ConsoleInterface/Menu.cpp
index 4112ed2..07be42e 100644
--- a/src/ConsoleInterface/Menu.cpp
+++ b/src/ConsoleInterface/Menu.cpp
@@ -17,6 +17,14 @@ void Menu::addCommand(const Command& command) {
menuOptions.add(command);
}
+bool error = false;
+String errMessage;
+
+void Menu::registerError(const char* message) {
+ error = true;
+ errMessage = message;
+}
+
void Menu::navigate() const {
if (menuOptions.get_count() == 0) {
printLine("Menu is empty!");
@@ -24,7 +32,6 @@ void Menu::navigate() const {
}
unsigned buffer = 1; // We immedeately read the value of buffer, so this is fine
- bool error = false;
while (buffer != 0) {
printTitle(title);
@@ -35,7 +42,7 @@ void Menu::navigate() const {
printOrderedListElem(menuOptions[i].get_nameInMenu());
if (error) {
- printError("Invalid menu option!");
+ printError(errMessage.get_cstr());
error = false;
}
diff --git a/src/ConsoleInterface/Menu.h b/src/ConsoleInterface/Menu.h
index 3ee4b0b..a4ee3c6 100644
--- a/src/ConsoleInterface/Menu.h
+++ b/src/ConsoleInterface/Menu.h
@@ -14,6 +14,7 @@ public:
Menu(const char* title, const Command* commands, unsigned commandCount);
void addCommand(const Command& command);
+ void registerError(const char* message);
void navigate() const;
};