-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConj_contenedor.cc
72 lines (60 loc) · 1.7 KB
/
Conj_contenedor.cc
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
#include "Conj_contenedor.hh"
#include <iostream>
using namespace std;
Conj_contenedor::Conj_contenedor() {
map<string,Segmento> ccont;
}
Conj_contenedor::Conj_contenedor(const Conj_contenedor& c) {
map<string,Segmento> ccont = c.ccont;
}
Conj_contenedor::~Conj_contenedor() {}
bool Conj_contenedor::existeix_cont(string mat) {
map<string,Segmento>::iterator it = ccont.find(mat);
return (it != ccont.end());
}
bool Conj_contenedor::esta_buit() {
map<string,Segmento>::iterator it = ccont.begin();
return (it == ccont.end());
}
int Conj_contenedor::longitud(string mat) const {
map<string,Segmento>::const_iterator it = ccont.find(mat);
Segmento g = it->second;
return (g.longitud());
}
Ubicacion Conj_contenedor::ubi(string mat) const {
map<string,Segmento>::const_iterator it;
it = ccont.find(mat);
Segmento g = it->second;
Ubicacion u = g.ubic();
return u;
}
void Conj_contenedor::print() const {
for (map<string,Segmento>::const_iterator it=ccont.begin(); it!=ccont.end(); ++it) {
Segmento g = it->second;
cout << it->first;
g.print();
cout << endl;
}
}
void Conj_contenedor::escriu_ubi_cont(Contenedor& cont) const {
string mat = cont.matricula();
map<string,Segmento>::const_iterator it;
it = ccont.find(mat);
Segmento g = it->second;
Ubicacion u = g.ubic();
u.print();
cout << endl;
}
void Conj_contenedor::afegeix_contenidor(const Contenedor& c, Ubicacion u) {
int l = c.longitud();
Segmento g(u,l);
ccont.insert(pair<string,Segmento> (c.matricula(), g));
}
void Conj_contenedor::elimina_contenidor(string mat) {
map<string,Segmento>::const_iterator it;
it = ccont.find(mat);
ccont.erase(it);
}
void Conj_contenedor::buidar() {
ccont.clear();
}