Compare commits

...

2 Commits

Author SHA1 Message Date
b685a3dfae Aufgabe 6: Verkehrsmittel 2026-04-29 17:08:29 +02:00
23f603b64b small fix 2026-04-17 08:03:52 +02:00
10 changed files with 126 additions and 2 deletions

View File

@ -14,6 +14,6 @@ struct Koerper{
Vektor mulVektor(const Vektor &vektor, const float &skalar);
Vektor addVektor(const Vektor &vektor1, const Vektor &vektor2);
Koerper bewegeKoerper(const Koerper &koerper, const Vektor &bewegung, const float &dt);
Koerper bewegeKoerper(const Koerper &koerper, const Vektor &gesamtkraft, const float &dt);
void ausgabeKoerper(const Koerper &koerper);
#endif

View File

@ -0,0 +1,15 @@
#include "Luftfahrzeug.h"
#include "Verkehrsmittel.h"
#include <string>
#include <sstream>
using namespace std;
string Luftfahrzeug::text()
{
stringstream ausgabe;
ausgabe << "Luftfahrzeug - Position x: " << x << "; Position y: " << y << "; max. Höhe: " << max_hoehe;
return ausgabe.str();
}

View File

@ -0,0 +1,15 @@
#pragma once
#include <string>
#include "Verkehrsmittel.h"
class Luftfahrzeug : public Verkehrsmittel{
int max_hoehe;
int z;
public:
Luftfahrzeug() : max_hoehe(0), z(0) {}
Luftfahrzeug(int max_hoehe) : max_hoehe(max_hoehe), z(0) {}
Luftfahrzeug(int max_hoehe, int z) : max_hoehe(max_hoehe), z(z) {}
std::string text();
};

14
6_Verkehrsmittel/PKW.h Normal file
View File

@ -0,0 +1,14 @@
#pragma once
#include "Verkehrsmittel.h"
#include "Radfahrzeug.h"
#include <string>
class PKW : public Radfahrzeug{
const int anzahl_tueren;
public:
PKW() : Radfahrzeug(4), anzahl_tueren(4) {}
PKW(int anzahl_raeder, int anzahl_tueren) : Radfahrzeug(anzahl_raeder), anzahl_tueren(anzahl_tueren) {}
string text();
};

View File

@ -0,0 +1,13 @@
#include "Radfahrzeug.h"
#include <sstream>
using namespace std;
string Radfahrzeug::text()
{
stringstream ausgabe;
ausgabe << "Radfahrzeug - Position x: " << x << "; Position y: " << y << "; Anzahl Räder: " << anzahl_raeder;
return ausgabe.str();
}

View File

@ -0,0 +1,14 @@
#pragma once
#include "Verkehrsmittel.h"
#include <string>
class Radfahrzeug : public Verkehrsmittel{
protected:
const int anzahl_raeder;
public:
Radfahrzeug() : anzahl_raeder(4) {}
Radfahrzeug(int anzahl_raeder) : anzahl_raeder(anzahl_raeder) {}
string text();
};

View File

@ -0,0 +1,20 @@
#include "Verkehrsmittel.h"
#include <sstream>
#include <string>
using namespace std;
void Verkehrsmittel::bewege(int zielx, int ziely)
{
x = zielx;
y = ziely;
}
string Verkehrsmittel::text()
{
stringstream ausgabe;
ausgabe << "Verkehrsmittel - Position x: " << x << "; Position y: " << y;
return ausgabe.str();
}

View File

@ -0,0 +1,18 @@
#pragma once
#include <string>
#include <iostream>
using namespace std;
class Verkehrsmittel{
protected:
int x;
int y;
public:
Verkehrsmittel () : x(0), y(0) {}
Verkehrsmittel(int x, int y) : x(x), y(y) {}
void bewege(int zielx, int ziely);
string text();
};

15
6_Verkehrsmittel/pkw.cpp Normal file
View File

@ -0,0 +1,15 @@
#include "PKW.h"
#include "Verkehrsmittel.h"
#include "Radfahrzeug.h"
#include <sstream>
using namespace std;
string PKW::text()
{
stringstream ausgabe;
ausgabe << "PKW - Position x: " << x << "; Position y: " << y << "; Anzahl Räder: " << anzahl_raeder << "; Anzahl Türen: " << anzahl_tueren;
return ausgabe.str();
}