Parkmanne/headers/Customer.h
2019-07-23 12:03:49 -03:00

55 lines
1.7 KiB
C++

#ifndef CUSTOMER_H
#define CUSTOMER_H
#pragma once
#include "Park_time.h"
#include <vector>
using std::vector;
/*
enum classes make it easy to represent categories.
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
*/
enum class Vehicle_type { twoweeler = 1, fourweeler = 2 };
/*
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.
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.
*/
class Customer {
public:
int id;
string name;
string password;
Vehicle_type vehicle;
string telephone;
int role;
Customer(string name_, string password_, Vehicle_type vehicle_, string telephone_, int role_);
Customer(int id_, string name_, string password_, Vehicle_type vehicle_,
vector<Park_time> instances, string telephone_, int role_);
void clock_in(int s_id);
void clock_out(int s_id);
bool parked();
int parked_at();
void update_db();
void delete_db();
private:
vector<Park_time> park_instances;
void save_db();
int auto_increment_db();
};
#endif // CUSTOMER_H