-
Notifications
You must be signed in to change notification settings - Fork 0
/
Parkhaus.cpp
43 lines (30 loc) · 878 Bytes
/
Parkhaus.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
#include"Parkhaus.h"
Parkhaus::Parkhaus(string s, vector<Stellplatz> v) : adresse(s), v(v) {
if (s == "") throw runtime_error("error adresse");
}
vector<Stellplatz> Parkhaus::finde(Ptyp typ) const {
vector<Stellplatz> vv;
for (int i = 0; i < v.size(); ++i) {
if (v[i].passt(typ) && v[i].ist_frei()) {
vv.push_back(v[i]);
}
}
return vv;
}
bool Parkhaus::einfahren(Ptyp typ) {
for (int i = 0; i < v.size(); ++i) {
if (v[i].ist_frei() && v[i].passt(typ)) {
v[i].einparken(typ);
return true;
}
}
return false;
}
void Parkhaus::ausfahren(size_t no) {
if (v.size() < no) throw runtime_error("error 80");
// if(v[no].ist_frei()) throw runtime_error ("error 80");
v[no].ausparken();
}
ostream &operator<<(ostream &o, const Parkhaus &s) {
return s.print(o);
}