-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBuilding.cpp
More file actions
37 lines (27 loc) · 797 Bytes
/
Building.cpp
File metadata and controls
37 lines (27 loc) · 797 Bytes
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
//
// Created by Paul Keck on 12.01.23.
//
#include "Building.h"
#include <sstream>
Building::Building(std::string name, int id, int gebPreis,
std::vector<Material*> benMaterialien ) :
gebäudeName(name), gebäudeID(id), gebäudePreis(gebPreis), materialien(benMaterialien)
{
}
int Building::berechneKosten() {
int result = gebäudePreis;
for(auto material : materialien) {
result += material->preis;
}
return result;
}
std::string Building::auflistung()
{
std::stringstream details;
details << gebäudeName << ": ";
for (auto material : materialien) {
details << material->materialName << "(" << material->preis << ") ";
}
details << "- Summe: " << berechneKosten();
return details.str();
}