Compare commits
18
Commits
Aufg1-dev-tobi
..
A6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8425f268b | ||
|
|
187ccdc6a5 | ||
|
|
3e50fa9c4d | ||
|
|
12eaaaa18d | ||
|
|
cf97b0ac1e | ||
|
|
9f0b35451b | ||
|
|
3b94f5d1b1 | ||
|
|
fada2730bf | ||
|
|
b636977ccd | ||
|
|
09c8ca75fe | ||
|
|
a7a85287d0 | ||
|
|
2b46522a4d | ||
|
|
643c524d1b | ||
|
|
3b1a8af39d | ||
|
|
be77aebb25 | ||
|
|
7618246a5b | ||
|
|
78de564416 | ||
|
|
7ae37fad48 |
@@ -1 +1,4 @@
|
|||||||
1_Grundlagen/code/matrix.exe
|
1_Grundlagen/code/matrix.exe
|
||||||
|
.out
|
||||||
|
.exe
|
||||||
|
.a
|
||||||
|
|||||||
Vendored
+28
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "cppbuild",
|
||||||
|
"label": "C/C++: g++ build active file",
|
||||||
|
"command": "/usr/bin/g++",
|
||||||
|
"args": [
|
||||||
|
"-fdiagnostics-color=always",
|
||||||
|
"-g",
|
||||||
|
"${file}",
|
||||||
|
"-o",
|
||||||
|
"${fileDirname}/${fileBasenameNoExtension}"
|
||||||
|
],
|
||||||
|
"options": {
|
||||||
|
"cwd": "${fileDirname}"
|
||||||
|
},
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
],
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"detail": "Task generated by Debugger."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": "2.0.0"
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -1,4 +1,3 @@
|
|||||||
#include <iostream>
|
|
||||||
#define NUM 0
|
#define NUM 0
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|||||||
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
@@ -1,45 +1,38 @@
|
|||||||
|
#include "flugkurve01.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main()
|
Vektor mulVektor(Vektor vec, float num) {
|
||||||
{
|
Vektor ergebnis = {vec.x * num, vec.y * num};
|
||||||
// Körper:
|
return ergebnis;
|
||||||
float masse = 10; // [kg]
|
}
|
||||||
float xPosition = 0; // [m]
|
|
||||||
float yPosition = 0; // [m]
|
|
||||||
float xGeschwindigkeit = 10; // [m/s]
|
|
||||||
float yGeschwindigkeit = 10; // [m/s]
|
|
||||||
|
|
||||||
// Parametrierung der auf den Körper wirkende Kräfte:
|
Vektor addVektor(Vektor vec1, Vektor vec2) {
|
||||||
const float X_BESCHLEUNIGUNG_GRAVITATION = 0; // [m/s^2]
|
Vektor erg = {vec1.x + vec2.x, vec1.y + vec2.y};
|
||||||
const float Y_BESCHLEUNIGUNG_GRAVITATION = -9.81; // [m/s^2]
|
return erg;
|
||||||
const float REIBUNGSKOEFFIZIENT = -5; // [kg/s]
|
}
|
||||||
|
|
||||||
// Sorgt dafür, dass 2 Nachkommastellen angezeigt werden:
|
Koerper bewegeKoerper(Koerper korp, Vektor gesamtkraft, float dt) {
|
||||||
cout << fixed;
|
|
||||||
cout.precision(2);
|
|
||||||
|
|
||||||
// Simulation:
|
// Berechnung der Beschleunigung aus der Kraft
|
||||||
const float dt = 0.1; // [s]
|
float xBeschleunigung = gesamtkraft.x / korp.masse;
|
||||||
for(;;)
|
float yBeschleunigung = gesamtkraft.y / korp.masse;
|
||||||
{
|
|
||||||
cout << "(" << xPosition << "," << yPosition << ")" << endl;
|
|
||||||
|
|
||||||
// Berechnung der Beschleunigung aus der Kraft
|
// Ermittlung der neuen Geschwindigkeit
|
||||||
float xBeschleunigung = xGeschwindigkeit * REIBUNGSKOEFFIZIENT / masse + X_BESCHLEUNIGUNG_GRAVITATION;
|
korp.geschwindigkeit.x += dt * xBeschleunigung;
|
||||||
float yBeschleunigung = yGeschwindigkeit * REIBUNGSKOEFFIZIENT / masse + Y_BESCHLEUNIGUNG_GRAVITATION;
|
korp.geschwindigkeit.y += dt * yBeschleunigung;
|
||||||
|
|
||||||
// Ermittlung der neuen Geschwindigkeit
|
// Ermittlung der neuen Position
|
||||||
xGeschwindigkeit += dt * xBeschleunigung;
|
korp.position.x += dt * korp.geschwindigkeit.x;
|
||||||
yGeschwindigkeit += dt * yBeschleunigung;
|
korp.position.y += dt * korp.geschwindigkeit.y;
|
||||||
|
return korp;
|
||||||
|
}
|
||||||
|
|
||||||
// Ermittlung der neuen Position
|
void ausgabeKoerper(Koerper korp){
|
||||||
xPosition += dt * xGeschwindigkeit;
|
cout << "x = " << korp.position.x << "y = " << korp.position.y;
|
||||||
yPosition += dt * yGeschwindigkeit;
|
}
|
||||||
|
|
||||||
if(yPosition<=0)
|
void ausgabeVektor(Vektor vec){
|
||||||
{
|
cout << "x = " << vec.x << endl;
|
||||||
break;
|
cout << "y = " << vec.y << endl;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Parametrierung der auf den Körper wirkende Kräfte:
|
||||||
|
struct Vektor {
|
||||||
|
float x; // [m/s^2]
|
||||||
|
float y; // [m/s^2]
|
||||||
|
};
|
||||||
|
// Körper:
|
||||||
|
struct Koerper {
|
||||||
|
float masse; // [kg]
|
||||||
|
Vektor position;
|
||||||
|
Vektor geschwindigkeit;
|
||||||
|
};
|
||||||
|
|
||||||
|
Vektor addVektor(Vektor vec1, Vektor vec2);
|
||||||
|
Vektor mulVektor(Vektor vec, float skalar);
|
||||||
|
Koerper bewegeKoerper(Koerper korp, Vektor gesamtkraft, float dt);
|
||||||
|
void ausgabeKoerper(Koerper korp);
|
||||||
|
void ausgabeVektor(Vektor vec);
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
const float* const wert
|
||||||
|
|
||||||
|
Welche Bedeuting haben das erste und zweite const?
|
||||||
|
1. const: es ist ein konstanter float
|
||||||
|
2. const: es ist ein konstanter zeiger
|
||||||
|
|
||||||
|
Welchen Nutzen könnte die Verwendung von const an den beiden Stellen bieten?
|
||||||
|
An der 1. Stelle: sichergehen, dass der Wert mit den gearbeitet wird nicht geändert wird
|
||||||
|
An der 2. Stelle: sichergehen, dass der Zeiger nicht auf etwas anderes zeigt, womit sich der Wert ändern würde.
|
||||||
Executable
BIN
Binary file not shown.
+22
-7
@@ -1,10 +1,25 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include "summe.h"
|
#include "summe.h"
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
int main()
|
int main() {
|
||||||
{
|
/* const int N = 4;
|
||||||
const int N = 4;
|
const float daten[N] = {1.0f,2.0f,3.0f,4.0f};
|
||||||
const float daten[N] = {1.0f,2.0f,3.0f,4.0f};
|
float summe = berechneSumme(daten,N);
|
||||||
float summe = berechneSumme(daten,N);
|
printf("Summe = %f\n", summe); */
|
||||||
printf("Summe = %f\n", summe);
|
string name;
|
||||||
|
int anzahlSummanten;
|
||||||
|
int hilfvar;
|
||||||
|
vector<int> summanten;
|
||||||
|
cout << "Was ist dein Name?" << endl;
|
||||||
|
cin >> name;
|
||||||
|
cout << "Hallo " << name << ", Wie viele Zahlen willst du addieren?" << endl;
|
||||||
|
cin >> anzahlSummanten;
|
||||||
|
for (int i = 0; i < anzahlSummanten; i++) {
|
||||||
|
cout << "Der " << i + 1 << ". Summant ist:" << endl;
|
||||||
|
cin >> hilfvar;
|
||||||
|
summanten.push_back(hilfvar);
|
||||||
|
}
|
||||||
|
cout << name << ", die Summe ist: " << berechneSumme(summanten) << endl;
|
||||||
|
cout << "Auf Wiedersehen " << name << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
+10
-5
@@ -1,8 +1,13 @@
|
|||||||
#include "summe.h"
|
#include "summe.h"
|
||||||
|
|
||||||
float berechneSumme(const float* const wert, int anzahlWerte)
|
/* float berechneSumme(const float *const wert, int anzahlWerte) {
|
||||||
{
|
return (anzahlWerte) ? *wert + berechneSumme(wert + 1, anzahlWerte - 1) : 0;
|
||||||
return (anzahlWerte) ? *wert+berechneSumme(wert+1, anzahlWerte-1) : 0;
|
} */
|
||||||
|
|
||||||
|
int berechneSumme(vector<int> myvector) {
|
||||||
|
int summe;
|
||||||
|
for (unsigned int i = 0; i < myvector.size(); i++) {
|
||||||
|
summe += myvector[i];
|
||||||
|
}
|
||||||
|
return summe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
#ifndef __SUMME_H
|
#ifndef __SUMME_H
|
||||||
#define __SUMME_H
|
#define __SUMME_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
using namespace std;
|
||||||
/**
|
/**
|
||||||
* Berechnet die Summe ueber eine Menge von Werten.
|
* Berechnet die Summe ueber eine Menge von Werten.
|
||||||
* @param wert Werte
|
* @param wert Werte
|
||||||
@@ -8,5 +10,5 @@
|
|||||||
* @return Summe
|
* @return Summe
|
||||||
*/
|
*/
|
||||||
float berechneSumme(const float* const wert, int anzahlWerte);
|
float berechneSumme(const float* const wert, int anzahlWerte);
|
||||||
|
int berechneSumme(vector<int> myvector);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Executable
BIN
Binary file not shown.
@@ -30,6 +30,7 @@ void function_checks() {
|
|||||||
assert(fabs(koerper.geschwindigkeit.x - 10.7) < 0.1 && "Result must be 10.7");
|
assert(fabs(koerper.geschwindigkeit.x - 10.7) < 0.1 && "Result must be 10.7");
|
||||||
assert(fabs(koerper.geschwindigkeit.y - 9.3) < 0.1 && "Result must be 9.3");
|
assert(fabs(koerper.geschwindigkeit.y - 9.3) < 0.1 && "Result must be 9.3");
|
||||||
assert(fabs(koerper.position.x - 74.9) < 0.1 && "Result must be 74.9");
|
assert(fabs(koerper.position.x - 74.9) < 0.1 && "Result must be 74.9");
|
||||||
|
cout << koerper.position.y << endl;
|
||||||
assert(fabs(koerper.position.y - 65.1) < 0.1 && "Result must be 65.1");
|
assert(fabs(koerper.position.y - 65.1) < 0.1 && "Result must be 65.1");
|
||||||
cout << "bewegeKoerper erfolgreich" << endl;
|
cout << "bewegeKoerper erfolgreich" << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,45 +1,38 @@
|
|||||||
|
#include "flugkurve02.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main()
|
Vektor mulVektor(const Vektor &vec, const float &skalar){
|
||||||
{
|
Vektor ergebnis = {vec.x * skalar, vec.y * skalar};
|
||||||
// Körper:
|
return ergebnis;
|
||||||
float masse = 10; // [kg]
|
}
|
||||||
float xPosition = 0; // [m]
|
|
||||||
float yPosition = 0; // [m]
|
|
||||||
float xGeschwindigkeit = 10; // [m/s]
|
|
||||||
float yGeschwindigkeit = 10; // [m/s]
|
|
||||||
|
|
||||||
// Parametrierung der auf den Körper wirkende Kräfte:
|
Vektor addVektor(const Vektor &vec1, const Vektor &vec2) {
|
||||||
const float X_BESCHLEUNIGUNG_GRAVITATION = 0; // [m/s^2]
|
Vektor erg = {vec1.x + vec2.x, vec1.y + vec2.y};
|
||||||
const float Y_BESCHLEUNIGUNG_GRAVITATION = -9.81; // [m/s^2]
|
return erg;
|
||||||
const float REIBUNGSKOEFFIZIENT = -5; // [kg/s]
|
}
|
||||||
|
|
||||||
// Sorgt dafür, dass 2 Nachkommastellen angezeigt werden:
|
Koerper bewegeKoerper(const Koerper &korp, const Vektor &gesamtkraft,const float &dt) {
|
||||||
cout << fixed;
|
Koerper erg = {0, {0,0}, {0,0}};
|
||||||
cout.precision(2);
|
// Berechnung der Beschleunigung aus der Kraft
|
||||||
|
const float xBeschleunigung = gesamtkraft.x / korp.masse;
|
||||||
|
const float yBeschleunigung = gesamtkraft.y / korp.masse;
|
||||||
|
|
||||||
// Simulation:
|
// Ermittlung der neuen Geschwindigkeit
|
||||||
const float dt = 0.1; // [s]
|
erg.geschwindigkeit.x = korp.geschwindigkeit.x + dt * xBeschleunigung;
|
||||||
for(;;)
|
erg.geschwindigkeit.y = korp.geschwindigkeit.y + dt * yBeschleunigung;
|
||||||
{
|
|
||||||
cout << "(" << xPosition << "," << yPosition << ")" << endl;
|
|
||||||
|
|
||||||
// Berechnung der Beschleunigung aus der Kraft
|
// Ermittlung der neuen Position
|
||||||
float xBeschleunigung = xGeschwindigkeit * REIBUNGSKOEFFIZIENT / masse + X_BESCHLEUNIGUNG_GRAVITATION;
|
erg.position.x += korp.position.x + dt * erg.geschwindigkeit.x;
|
||||||
float yBeschleunigung = yGeschwindigkeit * REIBUNGSKOEFFIZIENT / masse + Y_BESCHLEUNIGUNG_GRAVITATION;
|
erg.position.y += korp.position.y + dt * erg.geschwindigkeit.y;
|
||||||
|
return erg;
|
||||||
|
}
|
||||||
|
|
||||||
// Ermittlung der neuen Geschwindigkeit
|
void ausgabeKoerper(const Koerper &korp){
|
||||||
xGeschwindigkeit += dt * xBeschleunigung;
|
cout << "x = " << korp.position.x << "y = " << korp.position.y;
|
||||||
yGeschwindigkeit += dt * yBeschleunigung;
|
}
|
||||||
|
|
||||||
// Ermittlung der neuen Position
|
void ausgabeVektor(const Vektor &vec){
|
||||||
xPosition += dt * xGeschwindigkeit;
|
cout << "x = " << vec.x << endl;
|
||||||
yPosition += dt * yGeschwindigkeit;
|
cout << "y = " << vec.y << endl;
|
||||||
|
|
||||||
if(yPosition<=0)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Parametrierung der auf den Körper wirkende Kräfte:
|
||||||
|
struct Vektor {
|
||||||
|
float x; // [m/s^2]
|
||||||
|
float y; // [m/s^2]
|
||||||
|
};
|
||||||
|
// Körper:
|
||||||
|
struct Koerper {
|
||||||
|
float masse; // [kg]
|
||||||
|
Vektor position;
|
||||||
|
Vektor geschwindigkeit;
|
||||||
|
};
|
||||||
|
|
||||||
|
Vektor addVektor(const Vektor &vec1, const Vektor &vec2);
|
||||||
|
Vektor mulVektor(const Vektor &vec, const float &skalar);
|
||||||
|
Koerper bewegeKoerper(const Koerper &korp, const Vektor &gesamtkraft,const float &dt);
|
||||||
|
void ausgabeKoerper(const Koerper &korp);
|
||||||
|
void ausgabeVektor(const Vektor &vec);
|
||||||
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
@@ -4,4 +4,39 @@
|
|||||||
#include "flugkurve03.h"
|
#include "flugkurve03.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
//to be implemented
|
|
||||||
|
void Vektor::mul(const float &skalar){
|
||||||
|
this->x *= skalar;
|
||||||
|
this->y *= skalar;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vektor::add(const Vektor &vec2) {
|
||||||
|
this->x += vec2.x;
|
||||||
|
this->y += vec2.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Koerper::bewegen(const Vektor &beschleunigung,const float &dt) {
|
||||||
|
// Ermittlung der neuen Geschwindigkeit
|
||||||
|
this->geschwindigkeit.x += dt * beschleunigung.x;
|
||||||
|
this->geschwindigkeit.y += dt * beschleunigung.y;
|
||||||
|
|
||||||
|
// Ermittlung der neuen Position
|
||||||
|
this->position.x += dt * this->geschwindigkeit.x ;
|
||||||
|
this->position.y += dt * this->geschwindigkeit.y ;
|
||||||
|
}
|
||||||
|
float Koerper::liefereMasse(){
|
||||||
|
return this->masse;
|
||||||
|
}
|
||||||
|
Vektor Koerper::lieferePosition(){
|
||||||
|
return this->position;
|
||||||
|
}
|
||||||
|
Vektor Koerper::liefereGeschwindigkeit(){
|
||||||
|
return this->geschwindigkeit;
|
||||||
|
}
|
||||||
|
string Koerper::text(){
|
||||||
|
string outputX = to_string(this->position.x);
|
||||||
|
string outputY = to_string(this->position.y);
|
||||||
|
stringstream ganzeOut;
|
||||||
|
ganzeOut << "X= " << outputX << " Y= " << outputY;
|
||||||
|
return ganzeOut.str();
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,36 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
// to be defined
|
#pragma once
|
||||||
|
|
||||||
|
// Parametrierung der auf den Körper wirkende Kräfte:
|
||||||
|
class Vektor {
|
||||||
|
public:
|
||||||
|
float x; // [m/s^2]
|
||||||
|
float y; // [m/s^2]
|
||||||
|
Vektor() = default;
|
||||||
|
Vektor(float x, float y) {
|
||||||
|
this->x = x;
|
||||||
|
this->y = y;
|
||||||
|
}
|
||||||
|
void add(const Vektor &vec2);
|
||||||
|
void ausgabeVektor(const Vektor &vec);
|
||||||
|
void mul(const float &skalar);
|
||||||
|
};
|
||||||
|
// Körper:
|
||||||
|
class Koerper {
|
||||||
|
public:
|
||||||
|
float masse; // [kg]
|
||||||
|
Vektor position;
|
||||||
|
Vektor geschwindigkeit;
|
||||||
|
Koerper(float masse, Vektor position, Vektor geschwindigkeit) {
|
||||||
|
this->masse = masse;
|
||||||
|
this->position = position;
|
||||||
|
this->geschwindigkeit = geschwindigkeit;
|
||||||
|
};
|
||||||
|
float liefereMasse();
|
||||||
|
void bewegen(const Vektor &gesamtkraft, const float &dt);
|
||||||
|
Vektor lieferePosition();
|
||||||
|
Vektor liefereGeschwindigkeit();
|
||||||
|
string text();
|
||||||
|
};
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
@@ -0,0 +1,15 @@
|
|||||||
|
# Klassen:
|
||||||
|
- Verkehrsmittel
|
||||||
|
- Posistion (int x, int y)
|
||||||
|
- bewegen(neue Posistion)
|
||||||
|
- text()
|
||||||
|
- Luftfahrzeuge
|
||||||
|
- max. Flughöhe
|
||||||
|
- text()
|
||||||
|
- Radfahrzeuge
|
||||||
|
- Anzahl Räder
|
||||||
|
- text()
|
||||||
|
- Pkw
|
||||||
|
- Anzahl Türen
|
||||||
|
- text()
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Verkehrsmittel.h"
|
||||||
|
class Luftfahrzeug : public Verkehrsmittel{
|
||||||
|
private:
|
||||||
|
int maxFlughöhe;
|
||||||
|
public:
|
||||||
|
Luftfahrzeug (int maxFlughöhe){
|
||||||
|
this->maxFlughöhe = maxFlughöhe;
|
||||||
|
};
|
||||||
|
std::string text();
|
||||||
|
};
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Radfahrzeug.h"
|
||||||
|
#include "Verkehrsmittel.h"
|
||||||
|
|
||||||
|
class PKW : public Radfahrzeug {
|
||||||
|
private:
|
||||||
|
int anzahlTüren;
|
||||||
|
|
||||||
|
public:
|
||||||
|
PKW(int raeder, int türen) : Radfahrzeug(raeder) { anzahlTüren = türen; }
|
||||||
|
std::string text();
|
||||||
|
};
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Verkehrsmittel.h"
|
||||||
|
|
||||||
|
class Radfahrzeug : public Verkehrsmittel {
|
||||||
|
private:
|
||||||
|
int anzahlRäder;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Radfahrzeug(int räder) { this->anzahlRäder = räder; }
|
||||||
|
std::string text();
|
||||||
|
int getRäder();
|
||||||
|
};
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
class Verkehrsmittel{
|
||||||
|
private:
|
||||||
|
int posX = 0;
|
||||||
|
int posY = 0;
|
||||||
|
public:
|
||||||
|
void bewege(int x, int y);
|
||||||
|
virtual std::string text();
|
||||||
|
int getX();
|
||||||
|
int getY();
|
||||||
|
};
|
||||||
Executable
BIN
Binary file not shown.
@@ -1,9 +1,10 @@
|
|||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <iostream>
|
||||||
#include "Verkehrsmittel.h"
|
#include "Verkehrsmittel.h"
|
||||||
#include "Luftfahrzeug.h"
|
#include "Luftfahrzeug.h"
|
||||||
#include "Radfahrzeug.h"
|
#include "Radfahrzeug.h"
|
||||||
#include "PKW.h"
|
#include "PKW.h"
|
||||||
|
using namespace std;
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
//Verkehrsmittel
|
//Verkehrsmittel
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
#include "Luftfahrzeug.h"
|
||||||
|
#include "PKW.h"
|
||||||
|
#include "Radfahrzeug.h"
|
||||||
|
#include "Verkehrsmittel.h"
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
// Verkehrsmittel - Position x: 0; Position y: 0
|
||||||
|
int Verkehrsmittel::getX() { return posX; }
|
||||||
|
int Verkehrsmittel::getY() { return posY; }
|
||||||
|
int Radfahrzeug::getRäder() { return anzahlRäder; }
|
||||||
|
|
||||||
|
void Verkehrsmittel::bewege(int x, int y) {
|
||||||
|
this->posX = x;
|
||||||
|
this->posY = y;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Verkehrsmittel::text() {
|
||||||
|
std::string Xstring = std::to_string(getX());
|
||||||
|
std::string Ystring = std::to_string(getY());
|
||||||
|
std::string Fahrzeug = "Verkehrsmittel";
|
||||||
|
std::stringstream output;
|
||||||
|
output << Fahrzeug << " - " << "Position x: " << Xstring
|
||||||
|
<< "; Position y: " << Ystring;
|
||||||
|
return output.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Luftfahrzeug::text() {
|
||||||
|
std::string Xstring = std::to_string(getX());
|
||||||
|
std::string Ystring = std::to_string(getY());
|
||||||
|
std::string FlughöheString = std::to_string(maxFlughöhe);
|
||||||
|
std::string Fahrzeug = "Luftfahrzeug";
|
||||||
|
std::stringstream output;
|
||||||
|
output << Fahrzeug << " - " << "Position x: " << Xstring
|
||||||
|
<< "; Position y: " << Ystring << "; max. Höhe: " << FlughöheString;
|
||||||
|
return output.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string Radfahrzeug::text() {
|
||||||
|
std::string Xstring = std::to_string(getX());
|
||||||
|
std::string Ystring = std::to_string(getY());
|
||||||
|
std::string RäderString = std::to_string(anzahlRäder);
|
||||||
|
std::string Fahrzeug = "Radfahrzeug";
|
||||||
|
std::stringstream output;
|
||||||
|
output << Fahrzeug << " - " << "Position x: " << Xstring
|
||||||
|
<< "; Position y: " << Ystring << "; Anzahl Räder: " << RäderString;
|
||||||
|
return output.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string PKW::text() {
|
||||||
|
std::string Xstring = std::to_string(getX());
|
||||||
|
std::string Ystring = std::to_string(getY());
|
||||||
|
std::string Räderstring = std::to_string(getRäder());
|
||||||
|
std::string TürenString = std::to_string(anzahlTüren);
|
||||||
|
std::string Fahrzeug = "PKW";
|
||||||
|
std::stringstream output;
|
||||||
|
output << Fahrzeug << " - " << "Position x: " << Xstring
|
||||||
|
<< "; Position y: " << Ystring << "; Anzahl Räder: " << Räderstring
|
||||||
|
<< "; Anzahl Türen: " << TürenString;
|
||||||
|
return output.str();
|
||||||
|
}
|
||||||
Executable
BIN
Binary file not shown.
Reference in New Issue
Block a user