Parkmanne/Customer.cpp
2019-06-24 21:09:33 -03:00

59 lines
1.5 KiB
C++

#include "headers/Customer.h"
#include <iostream>
#include <random>
#include <ctime>
// moet aangepast worden om een verhicle_type toe te voegen
Customer::Customer(int id_, string name_, Verhicle_type verhicle_)
: id { id_ }
, name { name_ }
, card_code{gen_cardcode()}
, verhicle{verhicle_}
{
}
/*
generates a cardcode that can be stored on a card that can be used to authenticate.
Before that, some random generator starter settings.
*/
std::mt19937 mt(time(0));
std::uniform_int_distribution<int> dist(48, 90); // anything between and including ascii 48(0) and 90(z)
string Customer::gen_cardcode (){
string code;
for (int i = 0; i < 20; i++){
code += char(dist(mt));
}
return code;
}
/*
creert een park_time object met start time= nu, en voegt t toe aan een vector.
*/
void Customer::clock_in( int s_id)
{
Park_time pt{id, s_id};
park_instances.push_back(pt);
}
// edit de laatste park_time obj in de vector zodat de end_time = now.
void Customer::clock_out(int s_id){
park_instances[park_instances.size()-1].clock_out(id, s_id);
}
// monthly report generation. moet nog een manier vinden om af te bakenen.
void Customer::gen_monthly(){
std::cout << "NAME: " << name << " card code: " << card_code << "\n";
std::cout << "-------------------------------------------------\n";
for (auto& i : park_instances) {
// TODO: need some logic to only include from this month
std::cout << i;
}
std::cout << "-------------------------------------------------\n\n";
}