Website Summary Files Commits Branches @commit @diff @stats
path: root / src / ConsoleInterface
diff options
context:
space:
mode:
Commit7ff3d608fa74a656ad6362a433cbfe5df412fdc1 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-05 15:08:58 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2022-05-05 15:08:58 +0300
Filesc261ac36b160b81514c165173b2169469f35cc20 /src/ConsoleInterface
FMI-OOP-P1_TicketSystem-7ff3d608fa74a656ad6362a433cbfe5df412fdc1.tar
FMI-OOP-P1_TicketSystem-7ff3d608fa74a656ad6362a433cbfe5df412fdc1.tar.gz
FMI-OOP-P1_TicketSystem-7ff3d608fa74a656ad6362a433cbfe5df412fdc1.zip
Parent8796882268879807962441c1667ad32cf08938c2 (diff)
Autocommit at 05.05.2022 @ 15:08
1 files changed, 7 insertions, 1 deletions
-rw-r--r--src/ConsoleInterface/Menu.cpp8
diff --git a/src/ConsoleInterface/Menu.cpp b/src/ConsoleInterface/Menu.cpp
index bc1c5f1..3df71ae 100644
--- a/src/ConsoleInterface/Menu.cpp
+++ b/src/ConsoleInterface/Menu.cpp
@@ -22,6 +22,7 @@ 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);
@@ -31,13 +32,18 @@ void Menu::navigate() const {
for (unsigned i = 0; i < menuOptions.get_count(); i++)
printOrderedListElem(menuOptions[i].get_nameInMenu());
+ if (error) {
+ printError("Invalid menu option!");
+ error = false;
+ }
+
_printInputBoxLabel("Execute No [0-");
print(menuOptions.get_count());
print("]: ");
read(buffer);
if (buffer > menuOptions.get_count())
- printError("Invalid menu option!");
+ error = true;
else if (buffer > 0)
menuOptions[buffer - 1].run();
}