diff --git a/Interface.cpp b/Interface.cpp index 27e06c9..996bc78 100644 --- a/Interface.cpp +++ b/Interface.cpp @@ -12,6 +12,7 @@ void interface(vector& spots) { text_animation(introduction, 50); */ __label__ exit; + system("CLS"); cout << "\nWelcome to the parking system. Please login..."; int id; string password; @@ -43,6 +44,7 @@ void interface_member(vector& spots, Customer& c) { cout << "\nLogged in succesfully!\n"; begin: + system("CLS"); cout << "Hello! " << c.name << ", please select an option:\n[1]Parking\n[2]Monthly report\n" "[3]Edit information\n[4]Exit\n"; @@ -55,17 +57,21 @@ begin: break; } case 2: { - cout << "Has not been implemented yet\n"; + string lol; + report_customer(c.id); + std::cout<<"Enter any character to continue..."; + std::cin>>lol; break; } case 3: { - cout << "Has not been implemented yet\n"; + edit_information(c); break; } case 4: { cout << "Exiting...\n"; + Sleep(2000); goto exit; break; } @@ -157,6 +163,7 @@ begin: break; } case 3: { + system("CLS"); cout << "[1] Make new customer\n"; cout << "[2] Make new admin\n"; cout << "[3] Return\n"; @@ -181,6 +188,8 @@ begin: break; } case 4: { + std::cout<<"Exiting..."; + Sleep(2000); goto exit; break; } break; @@ -191,6 +200,7 @@ begin: } goto begin; exit:; + } // --------- individual things. @@ -214,7 +224,7 @@ void park(Customer& c, vector& spots) { cin.ignore(10000, '\n'); for (Park_spot& i : spots) { if (i.id == parkID) { - if (verify()) { + if (confirm()) { i.clock(c); cout << "You have parked sucessfully!"; } @@ -231,7 +241,7 @@ void park(Customer& c, vector& spots) { query_parkspot_with_id(c.parked_at(), spots).clock(c); cout << "You have sucessfully clocked out."; } else { - cout << "OK, have a nice day."; // exit to customer login + cout << "OK, have a nice day."; } } exit:; @@ -254,7 +264,7 @@ void new_customer() { std::getline(cin, password); Customer newcustomer{name, password, Vehicle_type(vtype), telephone, role}; cout << "\nNew customer sucessfully created\n"; - if (verify()) + if (confirm()) newcustomer.update_db(); } @@ -272,22 +282,49 @@ void new_admin() { std::getline(cin, password); Customer newcustomer{name, password, Vehicle_type(vtype), telephone, role}; cout << "\nNew customer sucessfully created\n"; - if (verify()) + if (confirm()) newcustomer.update_db(); } void new_parkspot(vector& spots) { - cout << "What type of parking spot? \n[1] Twowheeler\n[2] Fourwheeler\n"; + cout << "What type of parking spot? \n[1] Two-wheeler\n[2] Four-wheeler\n"; int vtype; cin >> vtype; cin.ignore(10000, '\n'); Park_spot newspot{Vehicle_type(vtype)}; - if (verify()) { + if (confirm()) { spots.push_back(newspot); cout << "New parking spot sucessfully created.\n"; } } +void edit_information(Customer& c) +{ + string string0; int int0; + /*std::cout<<"\nInput to update name or press [0] to keep name:\n"; + std::getline(cin,string0); + if (string0=="0"); + else c.name=string0;*/ + + std::cout<<"\n Input to update vehicle to [1]Two-Wheeler," + "[2]Four-Wheeler or press [0] to keep vehicle type:\n"; + std::cin>>int0; + if (!int0); + else c.vehicle=Vehicle_type(int0); + cin.ignore(); + std::cout<<"\n Input to update password or press [0] to keep current password:\n"; + std::getline(cin,string0); + if (string0=="0"); + else c.password=hash_password(string0); + + std::cout<<"\n Input to update phone number or press [0] to keep current number:\n"; + std::getline(cin,string0); + if (string0=="0"); + else c.telephone=string0; + c.role=0; + if(confirm()){c.update_db();} +} + // time stuff----------------------------------------------------- pair create_month_period() { @@ -323,16 +360,24 @@ pair create_week_period() { return period; } -bool verify(void) { +bool confirm(void) { string ver; std::cout << "\nAre you sure you want to commit these actions?" "\n[No] Revert." "\n[Yes] Commit."; std::cin >> ver; if (ver == "YES" | ver == "Yes" | ver == "yes") + { + std::cout<<"Succes! Changes Saved."; + Sleep(1000); return true; + } else + { + std::cout<<"No changes committed."; + Sleep(1000); return false; + } } // ------------------------------ report stuff diff --git a/headers/Interface.h b/headers/Interface.h index 2c3922a..4e4c258 100644 --- a/headers/Interface.h +++ b/headers/Interface.h @@ -1,7 +1,10 @@ #include "Query.h" +#include +#include using std::cin; +//interface functions void interface(vector& spots); void interface_member(vector& spots, Customer& c); void interface_admin(vector& spots); @@ -9,15 +12,16 @@ void park(Customer& c, vector& spots); void new_customer(); void new_admin(); void new_parkspot(vector& spots); +void edit_information(Customer&); // time creation pair create_month_period(); pair create_week_period(); -// report stuff +// report functions void report_single_spot(bool weekly = false); void report_all_spots(bool weekly = false); void report_customer(int customerID, bool weekly = false); -// stuff -bool verify(); \ No newline at end of file +// confirmation function +bool confirm(); \ No newline at end of file