Compare commits
10
Commits
a7a85287d0
...
A6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8425f268b | ||
|
|
187ccdc6a5 | ||
|
|
3e50fa9c4d | ||
|
|
12eaaaa18d | ||
|
|
cf97b0ac1e | ||
|
|
9f0b35451b | ||
|
|
3b94f5d1b1 | ||
|
|
fada2730bf | ||
|
|
b636977ccd | ||
|
|
09c8ca75fe |
No files matched your search
Executable
BIN
Binary file not shown.
@@ -4,4 +4,39 @@
|
||||
#include "flugkurve03.h"
|
||||
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>
|
||||
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 <iostream>
|
||||
#include "Verkehrsmittel.h"
|
||||
#include "Luftfahrzeug.h"
|
||||
#include "Radfahrzeug.h"
|
||||
#include "PKW.h"
|
||||
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
//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