Parkmanne/headers/old/Customer.h

55 lines
1.7 KiB
C
Raw Normal View History

2019-07-02 00:18:52 +00:00
#ifndef CUSTOMER_H
#define CUSTOMER_H
#pragma once
#include "Park_time.h"
#include <vector>
using std::vector;
2019-07-02 18:40:37 +00:00
/*
enum classes make it easy to represent categories.
2019-07-23 14:17:55 +00:00
So you can use something like Vehicle_type::twowheeler instead of 2 in code, so you know it's that.
but under the hood, it's still an int.
This is so you don't have to polute the global namespace with unnecesary variables.
enum classes do not permit implicit conversion between int and the enum class, and are in the
Enumclass:: scope in contrast to plain enums. https://en.cppreference.com/w/cpp/language/enum
2019-07-02 18:40:37 +00:00
*/
2019-07-08 20:57:09 +00:00
enum class Vehicle_type { twoweeler = 1, fourweeler = 2 };
2019-07-02 00:18:52 +00:00
/*
2019-07-02 18:40:37 +00:00
Customer constructors do the same stuff as all the other constructors.
clock_in and out create and modify park_time objects and store them to
park_instances. Technically, now that we have a working db, we don't need it.
2019-07-23 14:17:55 +00:00
It might have some performance benefits to keeping it, though.
TODO: test or fix this.
save, update, delete and auto increment are the same as in park_time but for customers.
2019-07-02 18:40:37 +00:00
*/
2019-07-02 00:18:52 +00:00
class Customer {
public:
int id;
string name;
string password;
2019-07-08 20:57:09 +00:00
Vehicle_type vehicle;
string telephone;
int role;
2019-07-22 13:16:07 +00:00
Customer(string name_, string password_, Vehicle_type vehicle_, string telephone_, int role_);
2019-07-06 14:52:01 +00:00
Customer(int id_, string name_, string password_, Vehicle_type vehicle_,
2019-07-22 13:16:07 +00:00
vector<Park_time> instances, string telephone_, int role_);
2019-07-02 00:18:52 +00:00
void clock_in(int s_id);
void clock_out(int s_id);
2019-07-06 16:32:00 +00:00
bool parked();
int parked_at();
2019-07-02 00:18:52 +00:00
void update_db();
void delete_db();
private:
vector<Park_time> park_instances;
void save_db();
int auto_increment_db();
};
#endif // CUSTOMER_H