Initial commit

This commit is contained in:
studavrije7683
2021-10-15 08:36:02 +02:00
commit d3138a4b13
89 changed files with 2898 additions and 0 deletions
@@ -0,0 +1,54 @@
#include<iostream>
#include <cstdlib>
using namespace std;
class Tier
{
private:
float Einnahme;
float Gewicht;
float Tagespreis;
void Daten_abfragen() //Deklaration und Definition der Methode Daten_abfragen
{
cout << "Wie steht der Tagespreis? " << endl;
cin >> Tagespreis;
cout << "Wie ist das Gewicht? " << endl;
cin >> Gewicht;
}
public:
//Konstruktor
Tier()
{
Daten_abfragen();
};
Tier(float g, float t):Gewicht(g), Tagespreis(t){ }
//Methode
void Einnahme_berechnen() //Deklaration und Definition der Methode Einnahme_berechnen
{
Einnahme = Gewicht*Tagespreis;
cout << "Einnahme: " << Einnahme << endl;
}
};
int main()
{
Tier schwein(19,2.5);
cout << "Schwein ";
schwein.Einnahme_berechnen();
Tier kuh;
cout << "Kuh ";
kuh.Einnahme_berechnen();
cout << endl << endl;
system("PAUSE");
return 0;
}
@@ -0,0 +1,51 @@
#include<iostream>
#include <cstdlib>
using namespace std;
class Auto
{
private:
string marke;
int kilometerstand;
static int anzahl_fahrten;
public:
Auto(string m, int k) : marke(m), kilometerstand(k) { }
~Auto()
{
cout << endl << "Objekt entfernt. " << endl;
}
void fahren(int gefahren) //Deklaration und Definition der Methode Daten_abfragen
{
kilometerstand += gefahren;
anzahl_fahrten++;
}
void daten_ausgeben()
{
cout << marke << ", aktueller Kilometerstand: " << kilometerstand << endl;
cout << "Anzahl an Fahrten: " << anzahl_fahrten << endl;
}
};
int Auto::anzahl_fahrten = 0;
int main()
{
Auto bmw("BMW",1500);
bmw.fahren(70);
bmw.daten_ausgeben();
bmw.fahren(80);
bmw.daten_ausgeben();
bmw.fahren(250);
bmw.daten_ausgeben();
cout << endl << endl;
system("PAUSE");
return 0;
}