so far, working
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
#ifndef CUSTOMER_H
|
||||
#define CUSTOMER_H
|
||||
#pragma once
|
||||
|
||||
#include "Park_time.h"
|
||||
#include "data.h"
|
||||
#include <vector>
|
||||
|
||||
using std::vector;
|
||||
|
||||
// will make it easy to represent it in the database while making it easy to use
|
||||
// while programming
|
||||
enum class Verhicle_type { bike = 1, small_car = 2, suv = 3, pickup = 4 };
|
||||
|
||||
/*
|
||||
card code is een randomly generated string moeten zijn, die je bv. op een nfc
|
||||
card zou opslaan en zo zou authenticaten bij je parking spot. We kunnen dit ipv
|
||||
of samen met een password gebruiken. clock in en out creeert en compleet een
|
||||
park_time object. Voegt het toe aan een vector.
|
||||
|
||||
*/
|
||||
|
||||
class Customer {
|
||||
public:
|
||||
|
||||
int id;
|
||||
string name;
|
||||
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);
|
||||
|
||||
void update_db();
|
||||
void delete_db();
|
||||
|
||||
void gen_monthly(); // remove, make it a function in data
|
||||
|
||||
private:
|
||||
Verhicle_type verhicle;
|
||||
vector<Park_time> park_instances;
|
||||
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
|
@@ -1,29 +0,0 @@
|
||||
#include "Customer.h"
|
||||
|
||||
/*
|
||||
db representation:
|
||||
int id not null
|
||||
bool taken not null
|
||||
int customer_id (null) (many to one, foreign key, whatever)
|
||||
|
||||
Dit representeert een parkeerplaats. Het heeft als internal state alleen dat t
|
||||
bezet is of niet.
|
||||
*/
|
||||
|
||||
class Park_spot {
|
||||
public:
|
||||
int id;
|
||||
bool taken;
|
||||
Customer* parked;
|
||||
Park_spot();
|
||||
Park_spot(Customer* parked_, int id_, bool taken_);
|
||||
void clock(Customer* c_customer);
|
||||
|
||||
private:
|
||||
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
|
@@ -1,44 +0,0 @@
|
||||
#ifndef PARK_TIME_H
|
||||
#define PARK_TIME_H
|
||||
#pragma once
|
||||
|
||||
#include "data.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
using namespace std::chrono;
|
||||
using std::cout;
|
||||
using std::string;
|
||||
using std::to_string;
|
||||
/*
|
||||
|
||||
|
||||
Record of who parked at what park_spot and at what time.
|
||||
*/
|
||||
|
||||
class Park_time {
|
||||
public:
|
||||
Park_time(int c_id, int s_id);
|
||||
Park_time(int id_, int customer_id_, int spot_id_, int start_,
|
||||
int duration_);
|
||||
int id;
|
||||
int customer_id;
|
||||
int spot_id;
|
||||
int duration;
|
||||
|
||||
void clock_out(int c_id, int s_id);
|
||||
friend std::ostream& operator<<(std::ostream& os, const Park_time& pt);
|
||||
|
||||
private:
|
||||
high_resolution_clock::time_point start;
|
||||
high_resolution_clock::time_point end;
|
||||
void save_db();
|
||||
void update_db();
|
||||
int auto_increment_db(); // helper
|
||||
int start_to_int(); // helper
|
||||
};
|
||||
|
||||
#endif // Park_time
|
@@ -1,18 +0,0 @@
|
||||
#ifndef QUERY_H
|
||||
#define QUERY_H
|
||||
#pragma once
|
||||
|
||||
#include "Park_spot.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
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
|
Reference in New Issue
Block a user