-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrajet.cpp
169 lines (153 loc) · 3.31 KB
/
trajet.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*Turikumwe Fabrice E.
Allan Tarcy*/
#include "trajet.hpp"
using namespace std;
Trajet::Trajet(Escales *portDep, Escales *portArr, Navire *nav, Date *dateDepart, Date *dateArrivee) : portDepart(portDep), portArrive(portArr), navire(nav), dateD(dateDepart), dateA(dateArrivee), prix(portDepart->getPrix() + portArrive->getPrix())
{
compagnie = navire->getCompagnie();
compagnie->AjoutTrajet(this);
}
Trajet::~Trajet()
{
passagers.clear();
billets.clear();
escales.clear();
seconds.clear();
matelots.clear();
delete portDepart;
delete portArrive;
delete navire;
delete compagnie;
delete capitaine;
delete dateD;
delete dateA;
}
void Trajet::ajoutEscales(Escales *e)
{
prix += e->getPrix();
escales.push_back(e);
}
void Trajet::ajoutPassager(Passager *p, Billet *b)
{
if (passagers.size() < navire->getCapacitePassagers())
{
passagers.push_back(p);
billets.push_back(b);
}
}
Escales *Trajet::getPortDepart()
{
return portDepart;
}
Escales *Trajet::getPortArrive()
{
return portArrive;
}
Compagnie *Trajet::getCompagnie()
{
return compagnie;
}
void Trajet::setPortDepart(Escales *portDep)
{
portDepart = portDep;
}
void Trajet::setPortArrive(Escales *portArr)
{
portArrive = portArr;
}
Date *Trajet::getDateD()const
{
return dateD;
}
Date *Trajet::getDateA()const
{
return dateA;
}
void Trajet::setDateD(Date *d)
{
dateD = d;
}
void Trajet::setDateA(Date *d)
{
dateA = d;
}
void Trajet::afficheEscales()
{
vector<Escales *>::iterator it;
for (it = escales.begin(); it != escales.end(); it++)
{
cout << (*it)->getNom() << endl;
}
}
void Trajet::affichePassagers()
{
vector<Passager *>::iterator it;
for (it = passagers.begin(); it != passagers.end(); it++)
{
cout << (*it)->getNom() << " " << (*it)->getPrenom() << " Categorie:" << (*it)->getCategorie() << endl;
}
if(passagers.empty() == true){
cout << "Pas de passager au moment..." << endl;
}
}
void Trajet::Affiche()
{
cout << "Depart: " << portDepart->getNom() << " - " << *dateD << ", " << "Arrivee: " << portArrive->getNom() << " - " << *dateA << ", Prix initial: " << prix << "$" << endl;
this->afficheEscales();
cout << "Passager:";
this->affichePassagers();
cout << endl;
}
int Trajet::getPrixInitial()
{
return prix;
}
vector<Billet *> Trajet::getBillets()
{
return billets;
}
Capitaine *Trajet::getCapitaine()
{
return capitaine;
}
vector<Second *> Trajet::getSeconds()
{
return seconds;
}
vector<Matelot *> Trajet::getMatelots()
{
return matelots;
}
void Trajet::setCapitaine(Capitaine *c)
{
if (navire->getTonnage() <= c->getTonnage())
{
capitaine = c;
}
}
void Trajet::ajouterSecond(Second *s)
{
if (seconds.size() <= navire->getMaxSeconds() && navire->getTonnage() < s->getTonnage())
{
seconds.push_back(s);
}
}
void Trajet::ajouterMatelot(Matelot *m)
{
if (matelots.size() <= navire->getMaxMatelots())
{
matelots.push_back(m);
}
}
void Trajet::ajoutPersonnel(Capitaine *cap, vector<Second *> s, vector<Matelot *> m)
{
capitaine = cap;
for (size_t i = 0; i < s.size(); i++)
{
this->ajouterSecond(s[i]);
}
for (size_t i = 0; i < m.size(); i++)
{
this->ajouterMatelot(m[i]);
}
}