update
This commit is contained in:
parent
d281783d58
commit
5dd8a33f1c
8
.gitignore
vendored
8
.gitignore
vendored
@ -13,3 +13,11 @@ CMakeUserPresets.json
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
my_project
|
my_project
|
||||||
.ccls-cache
|
.ccls-cache
|
||||||
|
*.out
|
||||||
|
*.o
|
||||||
|
*.a
|
||||||
|
*.so
|
||||||
|
*.dylib
|
||||||
|
*.dll
|
||||||
|
*.exe
|
||||||
|
*.zip
|
||||||
|
@ -19,4 +19,4 @@ Fahrzeug::Fahrzeug(std::string hersteller, std::string modell,
|
|||||||
this->ladungInProzent = ladungInProzent;
|
this->ladungInProzent = ladungInProzent;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fahrzeug::Fahrzeug() {}
|
Fahrzeug::Fahrzeug() = default;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "Fuhrpark_1.h"
|
#include "Fuhrpark_1.h"
|
||||||
#include "Fahrzeug.h"
|
#include "Fahrzeug.h"
|
||||||
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
void Fuhrpark_1::Add(const Fahrzeug &arg) {
|
void Fuhrpark_1::Add(const Fahrzeug &arg) {
|
||||||
@ -12,7 +13,10 @@ void Fuhrpark_1::Add(const Fahrzeug &arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Fuhrpark_1::Print() const {
|
void Fuhrpark_1::Print() const {
|
||||||
|
std::cout << "Fuhrpark 1:" << std::endl;
|
||||||
for (size_t i = 0; i < anzElem; ++i) {
|
for (size_t i = 0; i < anzElem; ++i) {
|
||||||
|
std::cout << "Fahrzeug " << i + 1 << ":" << std::endl;
|
||||||
pFuhrpark[i]->Print();
|
pFuhrpark[i]->Print();
|
||||||
}
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static const size_t Max_Elems = 100;
|
static const size_t Max_Elems = 100;
|
||||||
size_t anzElem;
|
size_t anzElem = 0;
|
||||||
Fahrzeug *pFuhrpark[Max_Elems];
|
Fahrzeug *pFuhrpark[Max_Elems];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
#include "Fuhrpark_2.h"
|
#include "Fuhrpark_2.h"
|
||||||
#include "Fahrzeug.h"
|
#include "Fahrzeug.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
void Fuhrpark_2::Add(const Fahrzeug &arg) {
|
void Fuhrpark_2::Add(const Fahrzeug &arg) {
|
||||||
pFuhrpark->push_back(new Fahrzeug(arg));
|
pFuhrpark->push_back(new Fahrzeug(arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fuhrpark_2::Print() const {
|
void Fuhrpark_2::Print() const {
|
||||||
|
std::cout << "Fuhrpark 2:" << std::endl;
|
||||||
for (size_t i = 0; i < pFuhrpark->size(); ++i) {
|
for (size_t i = 0; i < pFuhrpark->size(); ++i) {
|
||||||
|
std::cout << "Fahrzeug " << i + 1 << ":" << std::endl;
|
||||||
(*pFuhrpark)[i]->Print();
|
(*pFuhrpark)[i]->Print();
|
||||||
}
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ int main() {
|
|||||||
f2.Add(ts);
|
f2.Add(ts);
|
||||||
|
|
||||||
Fahrzeug pt("Porsche", "Taycan", "M-5678", 400, 90);
|
Fahrzeug pt("Porsche", "Taycan", "M-5678", 400, 90);
|
||||||
pt.Print();
|
|
||||||
f1.Add(pt);
|
f1.Add(pt);
|
||||||
f2.Add(pt);
|
f2.Add(pt);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user