Parkmanne/headers/Park_time.h

45 lines
906 B
C
Raw Normal View History

2019-05-28 16:46:55 +00:00
#ifndef PARK_TIME_H
#define PARK_TIME_H
#pragma once
#include "data.h"
2019-05-28 16:46:55 +00:00
#include <chrono>
#include <ctime>
2019-05-28 16:46:55 +00:00
#include <iostream>
2019-06-30 00:50:36 +00:00
#include <string>
2019-05-28 16:46:55 +00:00
using namespace std::chrono;
using std::cout;
2019-06-30 00:50:36 +00:00
using std::string;
using std::to_string;
2019-05-28 16:46:55 +00:00
/*
2019-06-30 01:48:49 +00:00
Record of who parked at what park_spot and at what time.
2019-05-28 16:46:55 +00:00
*/
class Park_time {
public:
2019-06-30 01:48:49 +00:00
Park_time(int c_id, int s_id);
Park_time(int id_, int customer_id_, int spot_id_, int start_,
int duration_);
~Park_time();
2019-05-28 16:46:55 +00:00
int id;
int customer_id;
int spot_id;
int duration;
2019-06-30 01:48:49 +00:00
2019-05-28 16:46:55 +00:00
void clock_out(int c_id, int s_id);
friend std::ostream& operator<<(std::ostream& os, const Park_time& pt);
2019-05-28 16:46:55 +00:00
private:
2019-05-28 16:46:55 +00:00
high_resolution_clock::time_point start;
high_resolution_clock::time_point end;
2019-06-30 00:50:36 +00:00
void save_db();
void update_db();
int auto_increment_db(); // helper
int start_to_int(); // helper
2019-05-28 16:46:55 +00:00
};
#endif // Park_time