1 Commits

Author SHA1 Message Date
3b45ae4d02 Cosmetic changes 2019-07-22 10:17:36 -03:00
5 changed files with 399 additions and 403 deletions

View File

@ -13,14 +13,13 @@ Customer::Customer(string name_, string password_, Vehicle_type vehicle_, string
}
Customer::Customer(int id_, string name_, string password_, Vehicle_type vehicle_,
vector<Park_time> instances, string telephone_, int role_)
vector<Park_time> instances, string telephone_)
: id{id_},
name{name_},
password{password_},
vehicle{vehicle_},
park_instances{instances},
telephone{telephone_},
role{role_} {}
telephone{telephone_} {}
// clock in/out methods
// ====================================================================================

View File

@ -1,12 +1,12 @@
#include "headers/Interface.h"
#include "headers/Interface.h"
// I added it to pass spots, because the parking options need it to check where
// is free parking_spots is declared in main, and if i declare it
// liberal use of
// cin.ignore(10000, '\n');
// so it skips to the next newline, in essence clearing the cin buffer
// I added it to pass spots, because the parking options need it to check where
// is free parking_spots is declared in main, and if i declare it
// liberal use of
// cin.ignore(10000, '\n');
// so it skips to the next newline, in essence clearing the cin buffer
void interface(vector<Park_spot>& spots) {
void interface(vector<Park_spot>& spots) {
/*
string introduction = "P A R K M A N N E"; //logo animation, disable during testing
text_animation(introduction, 50);
@ -36,14 +36,14 @@
} else {
cout << "ERROR ROLE_INVALID!";
}
exit:;
}
exit:;
}
void interface_member(vector<Park_spot>& spots, Customer& c) {
void interface_member(vector<Park_spot>& spots, Customer& c) {
__label__ begin, exit;
cout << "\nLogged in succesfully!\n";
begin:
begin:
system("CLS");
cout << "Hello! " << c.name
<< ", please select an option:\n[1]Parking\n[2]Monthly report\n"
@ -80,12 +80,12 @@
break;
}
goto begin;
exit:;
}
exit:;
}
void interface_admin(vector<Park_spot>& spots) {
void interface_admin(vector<Park_spot>& spots) {
__label__ begin, exit;
begin:
begin:
system("CLS");
cout << "\nWelcome to the admin interface\n";
cout << "\n[1] Reports & analytics";
@ -213,13 +213,13 @@
break;
}
goto begin;
exit:;
exit:;
}
}
// --------- individual things.
// --------- individual things.
void park(Customer& c, vector<Park_spot>& spots) {
void park(Customer& c, vector<Park_spot>& spots) {
__label__ exit;
cout << "You have selected parking option.\n";
if (!(c.parked())) {
@ -258,10 +258,10 @@
cout << "OK, have a nice day.";
}
}
exit:;
}
exit:;
}
void new_customer() {
void new_customer() {
int vtype;
string name;
string password;
@ -277,12 +277,12 @@
cout << "\nWhat's the password? ";
std::getline(cin, password);
Customer newcustomer{name, password, Vehicle_type(vtype), telephone, role};
cout << "\nNew customer sucessfully created with ID:" << newcustomer.id << "\n";
cout << "\nNew customer sucessfully created\n";
if (confirm())
newcustomer.update_db();
}
}
void new_admin() {
void new_admin() {
int vtype = 2; // revision required! Needs to be set to NULL
string name;
string password;
@ -294,13 +294,13 @@
std::getline(cin, telephone);
cout << "\nWhat's the password?";
std::getline(cin, password);
Customer newadmin{name, password, Vehicle_type(vtype), telephone, role};
cout << "\nNew customer sucessfully created with ID=" << newadmin.id << "\n";
Customer newcustomer{name, password, Vehicle_type(vtype), telephone, role};
cout << "\nNew customer sucessfully created\n";
if (confirm())
newadmin.update_db();
}
newcustomer.update_db();
}
void new_parkspot(vector<Park_spot>& spots) {
void new_parkspot(vector<Park_spot>& spots) {
cout << "What type of parking spot? \n[1] Two-wheeler\n[2] Four-wheeler\n";
int vtype;
cin >> vtype;
@ -310,10 +310,10 @@
spots.push_back(newspot);
cout << "New parking spot sucessfully created.\n";
}
}
}
void edit_information(Customer& c)
{
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);
@ -337,11 +337,11 @@
else c.telephone=string0;
c.role=0;
if(confirm()){c.update_db();}
}
}
// time stuff-----------------------------------------------------
// time stuff-----------------------------------------------------
pair<int, int> create_month_period() {
pair<int, int> create_month_period() {
std::time_t t = std::time(0);
std::tm* date = std::localtime(&t);
int month, year = 0;
@ -355,9 +355,9 @@
date->tm_mon = month;
period.second = mktime(date);
return period;
}
}
pair<int, int> create_week_period() {
pair<int, int> create_week_period() {
std::time_t t = std::time(0);
std::tm* date = std::localtime(&t);
int day, month, year = 0;
@ -372,9 +372,9 @@
period.first = mktime(date);
period.second = period.first + 604800; // plus 7 days in seconds.
return period;
}
}
bool confirm(void) {
bool confirm(void) {
string ver;
std::cout << "\nAre you sure you want to commit these actions?"
"\n[No] Revert."
@ -392,11 +392,11 @@
Sleep(1000);
return false;
}
}
}
// ------------------------------ report stuff
// ------------------------------ report stuff
void report_all_spots(bool weekly) {
void report_all_spots(bool weekly) {
pair<int, int> period;
if (weekly) {
period = create_week_period(); // remove the pair<int, int>
@ -407,9 +407,9 @@
cout << "working timeperiods: " << period.first << ", " << period.second; // DEBUG
reports_from_allparkspots(period); // TODO: namechange of reports_from_allparkspots in query?
}
}
void report_single_spot(bool weekly) {
void report_single_spot(bool weekly) {
cout << "Which parking spot would you like a report on?\n";
cout << "Parking spot ID: ";
int spotID;
@ -422,9 +422,9 @@
period = create_month_period();
}
reports_from_parkspot(spotID, period);
}
}
void report_customer(int customerID, bool weekly) {
void report_customer(int customerID, bool weekly) {
// use report_customer(0) to make interactive
// so admin can call the interactive version, but customer can only call
// report_customer(own_cid)
@ -439,4 +439,4 @@
period = create_month_period();
}
reports_from_customer(customerID, period);
}
}

View File

@ -41,10 +41,9 @@ vector<Customer> query_customer_with_name(string name) {
string password = query.getColumn(2);
int vehicle = query.getColumn(3); // cast to vehicle
string telephone = query.getColumn(4);
int role = query.getColumn(5);
vector<Park_time> park_instances = query_parktimes_for_customer(id);
result.push_back(
Customer{id, name_, password, Vehicle_type(vehicle), park_instances, telephone, role});
Customer{id, name_, password, Vehicle_type(vehicle), park_instances, telephone});
}
return result;
}
@ -64,10 +63,8 @@ Customer query_customer_with_id(int id) {
string password = query.getColumn(2);
int vehicle = query.getColumn(3); // cast to vehicle
string telephone = query.getColumn(4);
int role = query.getColumn(5);
vector<Park_time> park_instances = query_parktimes_for_customer(id);
Customer result{id, name, password, Vehicle_type(vehicle), park_instances, telephone, role};
Customer result{id, name, password, Vehicle_type(vehicle), park_instances, telephone};
return result;
}
}

View File

@ -41,9 +41,9 @@ class Customer {
Vehicle_type vehicle;
string telephone;
int role;
Customer(string name_, string password_, Vehicle_type vehicle_, string telephone_, int role_);
Customer(string name_, string password_, Vehicle_type vehicle_, string telephone_, int role);
Customer(int id_, string name_, string password_, Vehicle_type vehicle_,
vector<Park_time> instances, string telephone_, int role_);
vector<Park_time> instances, string telephone_);
void clock_in(int s_id);
void clock_out(int s_id);
bool parked();

BIN
test.db3

Binary file not shown.