intergration
This commit is contained in:
		@@ -6,7 +6,6 @@
 | 
			
		||||
// cin.ignore(10000, '\n');
 | 
			
		||||
// so it skips to the next newline, in essence clearing the cin buffer
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void interface(vector<Park_spot>& spots) {
 | 
			
		||||
    /*
 | 
			
		||||
    string introduction = "P A R K M A N N E"; //logo animation, disable during testing
 | 
			
		||||
@@ -26,7 +25,8 @@ void interface(vector<Park_spot>& spots) {
 | 
			
		||||
    while (!(verify_password(c.password, password))) {
 | 
			
		||||
        cout << "ERROR: wrong password. Please retype your password or type [x] to exit:\n";
 | 
			
		||||
        std::getline(cin, password);
 | 
			
		||||
        if(password=="x")goto exit;
 | 
			
		||||
        if (password == "x")
 | 
			
		||||
            goto exit;
 | 
			
		||||
    }
 | 
			
		||||
    if (query_role_customer(id) == 1) {
 | 
			
		||||
        interface_admin(spots);
 | 
			
		||||
@@ -35,15 +35,16 @@ void interface(vector<Park_spot>& spots) {
 | 
			
		||||
    } else {
 | 
			
		||||
        cout << "ERROR ROLE_INVALID!";
 | 
			
		||||
    }
 | 
			
		||||
    exit:;
 | 
			
		||||
exit:;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void interface_member(vector<Park_spot>& spots, Customer& c) {
 | 
			
		||||
    __label__ begin, exit;
 | 
			
		||||
    cout << "\nLogged in succesfully!\n";
 | 
			
		||||
 | 
			
		||||
    begin:
 | 
			
		||||
    cout <<"Hello! "<<c.name<< ", please select an option:\n[1]Parking\n[2]Monthly report\n"
 | 
			
		||||
begin:
 | 
			
		||||
    cout << "Hello! " << c.name
 | 
			
		||||
         << ", please select an option:\n[1]Parking\n[2]Monthly report\n"
 | 
			
		||||
            "[3]Edit information\n[4]Exit\n";
 | 
			
		||||
    int option;
 | 
			
		||||
    cin >> option;
 | 
			
		||||
@@ -73,12 +74,12 @@ void interface_member(vector<Park_spot>& spots, Customer& c) {
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
    goto begin;
 | 
			
		||||
    exit:;
 | 
			
		||||
exit:;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void interface_admin(vector<Park_spot>& spots) {
 | 
			
		||||
    __label__ begin,exit;
 | 
			
		||||
    begin:
 | 
			
		||||
    __label__ begin, exit;
 | 
			
		||||
begin:
 | 
			
		||||
    cout << "\nWelcome to the admin interface\n";
 | 
			
		||||
    cout << "\n[1] Reports & analytics";
 | 
			
		||||
    cout << "\n[2] Parking spots";
 | 
			
		||||
@@ -94,7 +95,8 @@ void interface_admin(vector<Park_spot>& spots) {
 | 
			
		||||
        cout << "[2] See weekly report of ALL parking spots\n";
 | 
			
		||||
        cout << "[3] See monthly report of a specific parking spot\n";
 | 
			
		||||
        cout << "[4] See weekly report of a specific parking spot\n";
 | 
			
		||||
        cout << "[5] Return\n";
 | 
			
		||||
        cout << "[5] See monthly report of a specific customer\n";
 | 
			
		||||
        cout << "[6] See weekly report of a specific customer\n";
 | 
			
		||||
        cout << "Enter option number: ";
 | 
			
		||||
        int option_1;
 | 
			
		||||
        cin >> option_1;
 | 
			
		||||
@@ -116,10 +118,15 @@ void interface_admin(vector<Park_spot>& spots) {
 | 
			
		||||
            report_single_spot(true);
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case 5:{
 | 
			
		||||
            goto begin;
 | 
			
		||||
        case 5: {
 | 
			
		||||
            report_customer(0);
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case 6: {
 | 
			
		||||
            report_customer(0, true);
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        default:
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
@@ -140,7 +147,7 @@ void interface_admin(vector<Park_spot>& spots) {
 | 
			
		||||
            new_parkspot(spots);
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case 3:{
 | 
			
		||||
        case 3: {
 | 
			
		||||
            goto begin;
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
@@ -166,22 +173,24 @@ void interface_admin(vector<Park_spot>& spots) {
 | 
			
		||||
            new_admin();
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case 3:{
 | 
			
		||||
        case 3: {
 | 
			
		||||
            goto begin;
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        default:
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        case 4: {goto exit;break;}
 | 
			
		||||
    case 4: {
 | 
			
		||||
        goto exit;
 | 
			
		||||
        break;
 | 
			
		||||
    } break;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    default:
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
    goto begin;
 | 
			
		||||
    exit:;
 | 
			
		||||
exit:;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// --------- individual things.
 | 
			
		||||
@@ -192,7 +201,7 @@ void park(Customer& c, vector<Park_spot>& spots) {
 | 
			
		||||
    if (!(c.parked())) {
 | 
			
		||||
        cout << "The following spots fit your vehicle and are available: \n";
 | 
			
		||||
        for (Park_spot i : spots) {
 | 
			
		||||
            if ((i.v_type == c.vehicle)&(i.taken==false)) {
 | 
			
		||||
            if ((i.v_type == c.vehicle) & (i.taken == false)) {
 | 
			
		||||
                cout << i.id << ", ";
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
@@ -200,12 +209,12 @@ void park(Customer& c, vector<Park_spot>& spots) {
 | 
			
		||||
        cout << "\nWhere do you want to park? Or type [0] to exit.";
 | 
			
		||||
        int parkID;
 | 
			
		||||
        cin >> parkID;
 | 
			
		||||
        if (!parkID)goto exit;
 | 
			
		||||
        if (!parkID)
 | 
			
		||||
            goto exit;
 | 
			
		||||
        cin.ignore(10000, '\n');
 | 
			
		||||
        for (Park_spot& i : spots) {
 | 
			
		||||
            if (i.id == parkID) {
 | 
			
		||||
                if (verify())
 | 
			
		||||
                {
 | 
			
		||||
                if (verify()) {
 | 
			
		||||
                    i.clock(c);
 | 
			
		||||
                    cout << "You have parked sucessfully!";
 | 
			
		||||
                }
 | 
			
		||||
@@ -225,7 +234,7 @@ void park(Customer& c, vector<Park_spot>& spots) {
 | 
			
		||||
            cout << "OK, have a nice day."; // exit to customer login
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    exit:;
 | 
			
		||||
exit:;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void new_customer() {
 | 
			
		||||
@@ -245,7 +254,8 @@ void new_customer() {
 | 
			
		||||
    std::getline(cin, password);
 | 
			
		||||
    Customer newcustomer{name, password, Vehicle_type(vtype), telephone, role};
 | 
			
		||||
    cout << "\nNew customer sucessfully created\n";
 | 
			
		||||
    if (verify())newcustomer.update_db();
 | 
			
		||||
    if (verify())
 | 
			
		||||
        newcustomer.update_db();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void new_admin() {
 | 
			
		||||
@@ -262,7 +272,8 @@ void new_admin() {
 | 
			
		||||
    std::getline(cin, password);
 | 
			
		||||
    Customer newcustomer{name, password, Vehicle_type(vtype), telephone, role};
 | 
			
		||||
    cout << "\nNew customer sucessfully created\n";
 | 
			
		||||
    if(verify())newcustomer.update_db();
 | 
			
		||||
    if (verify())
 | 
			
		||||
        newcustomer.update_db();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void new_parkspot(vector<Park_spot>& spots) {
 | 
			
		||||
@@ -271,8 +282,10 @@ void new_parkspot(vector<Park_spot>& spots) {
 | 
			
		||||
    cin >> vtype;
 | 
			
		||||
    cin.ignore(10000, '\n');
 | 
			
		||||
    Park_spot newspot{Vehicle_type(vtype)};
 | 
			
		||||
    if(verify()){spots.push_back(newspot);
 | 
			
		||||
    cout << "New parking spot sucessfully created.\n";}
 | 
			
		||||
    if (verify()) {
 | 
			
		||||
        spots.push_back(newspot);
 | 
			
		||||
        cout << "New parking spot sucessfully created.\n";
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// time stuff-----------------------------------------------------
 | 
			
		||||
@@ -310,16 +323,16 @@ pair<int, int> create_week_period() {
 | 
			
		||||
    return period;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool verify(void)
 | 
			
		||||
{
 | 
			
		||||
string ver;
 | 
			
		||||
std::cout<<"\nAre you sure you want to commit these actions?"
 | 
			
		||||
bool verify(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") return true;
 | 
			
		||||
else return false;
 | 
			
		||||
 | 
			
		||||
    std::cin >> ver;
 | 
			
		||||
    if (ver == "YES" | ver == "Yes" | ver == "yes")
 | 
			
		||||
        return true;
 | 
			
		||||
    else
 | 
			
		||||
        return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ------------------------------ report stuff
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										14
									
								
								main.cpp
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								main.cpp
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
			
		||||
#include "headers/Interface.h"
 | 
			
		||||
 | 
			
		||||
#include "headers/Interface.h"
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
Code structure is like this:
 | 
			
		||||
@@ -45,19 +45,9 @@ static vector<Park_spot> parking_spots = populate_spots();
 | 
			
		||||
static vector<Customer> park_customers;
 | 
			
		||||
 | 
			
		||||
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"
 | 
			
		||||
 | 
			
		||||
    while (true) {
 | 
			
		||||
        cin.clear();
 | 
			
		||||
        interface(parking_spots);
 | 
			
		||||
        cout << "\nexit? Input 'y' or 'n'..";
 | 
			
		||||
        char n;
 | 
			
		||||
        cin >> n;
 | 
			
		||||
        cin.clear();
 | 
			
		||||
        if (n == 'y') {
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user