almost all internals done after i fix segfault

This commit is contained in:
MassiveAtoms
2019-07-01 14:23:15 -03:00
parent 450ffc9588
commit 5fa84e866f
10 changed files with 127 additions and 96 deletions

View File

@@ -4,8 +4,6 @@
#include "Park_time.h"
#include "data.h"
#include <random>
#include <vector>
using std::vector;
@@ -24,16 +22,15 @@ park_time object. Voegt het toe aan een vector.
class Customer {
public:
Customer(string name_, Verhicle_type verhicle_);
Customer(int id_, string name_, // needed to construct from db
string card_code_,
Verhicle_type verhicle_, // TODO: how init. p_time instances?
vector<Park_time> instances);
~Customer();
int id;
string name;
string card_code;
string password;
Customer(string name_, string password_, Verhicle_type verhicle_);
Customer(int id_, string name_, // needed to construct from db
string password_,
Verhicle_type verhicle_, // TODO: how init. p_time instances?
vector<Park_time> instances);
void clock_in(int s_id);
void clock_out(int s_id);
@@ -45,10 +42,13 @@ class Customer {
private:
Verhicle_type verhicle;
vector<Park_time> park_instances;
string gen_cardcode();
void save_db();
int auto_increment_db();
};
static vector<Customer> park_customers; // save the customers that are parked in here
// parking_spot uses pointers, so it's better to save the parked customers here
// where we know they'll be destroyed at the end of this scope, instead of too early
// and end up with dangling pointers
#endif // CUSTOMER_H

View File

@@ -17,17 +17,13 @@ class Park_spot {
Customer* parked;
Park_spot();
Park_spot(Customer* parked_, int id_, bool taken_);
~Park_spot();
void
clock(Customer* c_customer);
void clock(Customer* c_customer);
private:
void
save_db();
void
update_db();
void
delete_db();
int
auto_increment_db();
};
void save_db();
void update_db();
void delete_db();
int auto_increment_db();
};
static vector<Park_spot> parking_spots; // to save the parking spots in memory

View File

@@ -4,11 +4,15 @@
#include "Park_spot.h"
#include <exception>
#include <array>
vector<Park_time> query_Parktime_for_customer(int cid);
vector<Park_time> query_parktimes_for_customer(int cid);
vector<Customer> query_customer_with_name(string name);
Customer query_customer_with_id(int id);
Customer* get_customer_ptr_for_parkspot(int id);
void query_all_parking_spots(); // used for initializing the parking spots at start of the program
#endif // CUSTOMER_H