Structure change
This commit is contained in:
37
headers/Customer.h
Normal file
37
headers/Customer.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifndef CUSTOMER_H
|
||||
#define CUSTOMER_H
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "Park_time.h"
|
||||
|
||||
using std::vector;
|
||||
using std::string;
|
||||
|
||||
/*
|
||||
db repr of Customer
|
||||
int id (not null, auto increment)
|
||||
string name (not nulll)
|
||||
string card_code (not null)
|
||||
|
||||
*/
|
||||
|
||||
class Customer {
|
||||
public:
|
||||
int id;
|
||||
string name;
|
||||
string card_code;
|
||||
void clock_in(int s_id);
|
||||
void clock_out(int s_id);
|
||||
// void gen_weekly(); TODO: this
|
||||
void gen_monthly();
|
||||
Customer(int id_, string name_, string card_code_);
|
||||
|
||||
private:
|
||||
vector<Park_time> park_instances;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // CUSTOMER_H
|
19
headers/Park_spot.h
Normal file
19
headers/Park_spot.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "Customer.h"
|
||||
|
||||
|
||||
/*
|
||||
db representation:
|
||||
int id not null
|
||||
bool taken not null
|
||||
int customer_id (null) (many to one, foreign key, whatever)
|
||||
*/
|
||||
|
||||
class Park_spot {
|
||||
public:
|
||||
int id;
|
||||
bool taken;
|
||||
Customer* parked; //TODO: think about memory management
|
||||
Park_spot(int id_);
|
||||
void clock(Customer* c_customer);
|
||||
private:
|
||||
};
|
40
headers/Park_time.h
Normal file
40
headers/Park_time.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef PARK_TIME_H
|
||||
#define PARK_TIME_H
|
||||
#pragma once
|
||||
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
using namespace std::chrono;
|
||||
|
||||
/*
|
||||
db repr of Park_time
|
||||
int id (not null, auto increment)
|
||||
int customer_id (not null) (many to one or something like that)
|
||||
int spot_id (not null, many to one or something like that)
|
||||
int duration
|
||||
datetime start (not null)
|
||||
datetime end
|
||||
*/
|
||||
|
||||
class Park_time {
|
||||
public:
|
||||
int id;
|
||||
int customer_id;
|
||||
int spot_id;
|
||||
int duration;
|
||||
Park_time(int c_id, int s_id);
|
||||
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;
|
||||
//TODO: discuss pros cons of using chrono, ctime, or 3th party lib
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // Park_time
|
Reference in New Issue
Block a user