-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuincaillerie.cpp
66 lines (57 loc) · 2.28 KB
/
Quincaillerie.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//--------------------------------------------------------
//
// Quincaillerie.h
//
// Définition de la classe Quincaillerie qui permet de
// créer une instance de quincaillerie qui permet
// d'ajouter ou enlever des clients à des caisses
// par Jonathan Boucard & Pierre-Anthony Houle, 2016
//--------------------------------------------------------
#include "Quincaillerie.h"
#include <algorithm>
#include <iostream>
Quincaillerie::Quincaillerie(int NBCaisse) : vCaisses(NBCaisse)
{
}
vector<Caisse>::iterator Quincaillerie::GetCaissePlusClients()
{
return max_element(GetVectorCaisse().begin(), GetVectorCaisse().end(), [] (const Caisse& a, const Caisse& b)
{return a.GetNbClientsNonServis() + a.GetNbClientsServis() < b.GetNbClientsNonServis() + b.GetNbClientsServis(); });
}
vector<Caisse>::iterator Quincaillerie::GetCaissePlusArgent()
{
return max_element(GetVectorCaisse().begin(), GetVectorCaisse().end(), [](const Caisse& a, const Caisse& b)
{ return a.GetTotalAchats() < b.GetTotalAchats(); });
}
vector<Caisse>::iterator Quincaillerie::GetCaissePlusAttente()
{
return max_element(GetVectorCaisse().begin(), GetVectorCaisse().end(), [](const Caisse& a, const Caisse& b)
{ return a.GetTempsFileTotal() < b.GetTempsFileTotal(); });
}
Caisse* Quincaillerie::GetCaissePlusRapide(bool commercial)
{
int indiceDepart; // L'indice de la première caisse selon le type de client
if (commercial == true) indiceDepart = 0;
else indiceDepart = 1;
bool caisseOuverte = false; // True si une caisse est ouverte dans la recherche si non false
Caisse* cRapide = &GetCaisse(indiceDepart); // Un pointeur sur la caisse aillant le moins de temps d'attente
for (int i = indiceDepart; i < GetVectorCaisse().size(); i++)
{
if (GetVectorCaisse().at(i).GetStatus() != FERMÉ)
{
caisseOuverte = true;
if (GetVectorCaisse().at(i).GetTempsFile() < cRapide->GetTempsFile())
cRapide = &GetVectorCaisse().at(i);
}
}
if (caisseOuverte == false && GetCaisse(indiceDepart).GetStatus() == OUVERT)
caisseOuverte = true;
if (!caisseOuverte)
throw exception("Il n'y a aucune caisse d'ouverte!");
return cRapide;
}
int Quincaillerie::ConvertirMinuteEnSeconde(string Min)
{
int NBSecondes = stoi(Min.substr(0, Min.find(":"))) * 60 + stoi(Min.substr(Min.find(":") + 1, Min.size()));
return NBSecondes;
}