From 5e33eaeede8c2f688bda43fbecaa75246322ce08 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 16 Jul 2019 18:26:49 -0300 Subject: [PATCH] Label for admin exit, main interface looped --- Interface.cpp | 19 ++++++++++++++++--- Query.cpp | 2 +- main.cpp | 3 +-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Interface.cpp b/Interface.cpp index 3aec372..d0ca8c2 100644 --- a/Interface.cpp +++ b/Interface.cpp @@ -27,6 +27,7 @@ void interface(vector& spots) { } void interface_member(vector& spots) { + __label__ exit; int id; string password; cout << "\nPlease input id:"; @@ -36,8 +37,9 @@ void interface_member(vector& spots) { cout << "\nPlease input password:"; std::getline(cin, password); while (!(verify_password(c.password, password))) { - cout << "ERROR: wrong password. Please retype your password:\n"; + cout << "ERROR: wrong password. Please retype your password or enter [exit] to exit :\n"; std::getline(cin, password); + if (password=="exit") goto exit; } cout << "Logged in succesfully\n"; @@ -58,9 +60,12 @@ void interface_member(vector& spots) { default: break; } + exit: ; } void interface_admin(vector& spots) { + __label__ exit, begin; + begin: ; cout << "Welcome to the admin interface. It is not completely ready yet.\n"; cout << "[1] See monthly report of ALL parking spots\n"; cout << "[2] See weekly report of ALL parking spots\n"; @@ -69,6 +74,7 @@ void interface_admin(vector& spots) { cout << "[5] See current status of parking spots\n"; cout << "[6] Make new customer\n"; cout << "[7] Make new parking spot\n"; + cout << "[8] Exit\n"; cout << "option[1-7]:"; int option; cin >> option; @@ -111,9 +117,16 @@ void interface_admin(vector& spots) { break; } + case 8: { + goto exit; + break; + } + default: break; } +goto begin; +exit: ; } // --------- individual things. @@ -175,11 +188,11 @@ void new_customer() { } void new_parkspot(vector& spots) { - cout << "What type of parking spot? [1] twoweeler, [2] fourweeler: "; + cout << "What type of parking spot? [1] Twowheeler, [2] Fourwheeler: "; int vtype; cin >> vtype; cin.ignore(10000, '\n'); Park_spot newspot{Vehicle_type(vtype)}; spots.push_back(newspot); - cout << "new parking spot sucessfully created.\n"; + cout << "New parking spot sucessfully created.\n"; } \ No newline at end of file diff --git a/Query.cpp b/Query.cpp index 8fcc5b0..e1b823e 100644 --- a/Query.cpp +++ b/Query.cpp @@ -154,7 +154,7 @@ void current_status_parkspots(vector& spots) { } } -// -------------- paroking spots +// -------------- parking spots // vector populate_spots(){ // vector spots; diff --git a/main.cpp b/main.cpp index 596b79c..3faaa1c 100644 --- a/main.cpp +++ b/main.cpp @@ -47,8 +47,7 @@ int main() { // state of db: // er zijn 10 parkspots, 5 met biketype en 5 met pickup type // er is een customer met id 1(testcustomer) met password "password" - - interface(parking_spots); +do { interface(parking_spots);} while (true); } /*