diff --git a/Aufgabenblock_1/main.cpp b/Aufgabenblock_1/main.cpp index d30685c..496f40d 100644 --- a/Aufgabenblock_1/main.cpp +++ b/Aufgabenblock_1/main.cpp @@ -123,7 +123,7 @@ void vAufgabe2() { (*it)->vAusgabe(); } - cout << endl << "Globale Zeit: " << dGlobaleZeit; + cout << endl << "Globale Zeit: " << dGlobaleZeit; } } @@ -134,8 +134,8 @@ void vAufgabe3() { dGlobaleZeit += 1.0; velo.vAbfertigung(); - vw.vAbfertigung(); - boat.vAbfertigung(); + vw.vAbfertigung(); + boat.vAbfertigung(); Fahrzeug::vAusgabeHeader(); cout << vw << endl << velo << endl << boat << endl << endl; @@ -146,7 +146,7 @@ void vAufgabe3() { else { cout << "Der Golf ist bereits weiter gefahren" << endl; } - cout << endl; + cout << endl; Fahrrad veloKopie = velo; /* benutze Kopier Konstrukutor */ Fahrrad veloKopie2; @@ -163,16 +163,16 @@ typedef void (*aufgabe_t)(void); int main() { int iWahl; - aufgabe_t pAufgaben[] = { - &vAufgabe1_deb, - &vAufgabe1, - &vAufgabe2, - &vAufgabe3 - }; + aufgabe_t pAufgaben[] = { + &vAufgabe1_deb, + &vAufgabe1, + &vAufgabe2, + &vAufgabe3 + }; retry: - cout << "0: vAufgabe1_deb()" << endl; + cout << "0: vAufgabe1_deb()" << endl; cout << "1: vAufgabe1()" << endl; cout << "2: vAufgabe2()" << endl; cout << "3: vAufgabe3()" << endl; @@ -180,20 +180,20 @@ int main() { cin >> iWahl; cout << endl; - if (iWahl > NUM_AUFGABEN || iWahl < 0) { - cerr << "Ungültige Eingabe! Bitte versuchen Sie es erneut" << endl; - goto retry; - } + if (iWahl > NUM_AUFGABEN || iWahl < 0) { + cerr << "Ungültige Eingabe! Bitte versuchen Sie es erneut" << endl; + goto retry; + } pAufgaben[iWahl](); /* Funktionspointer aufrufen */ cout << endl << endl << "Nochmal? (0/1): "; - cin >> iWahl; - cout << endl; + cin >> iWahl; + cout << endl; - if (iWahl) { - goto retry; - } + if (iWahl) { + goto retry; + } return 0; } diff --git a/Aufgabenblock_2/Fahrrad.cpp b/Aufgabenblock_2/Fahrrad.cpp index 61260a4..0714321 100644 --- a/Aufgabenblock_2/Fahrrad.cpp +++ b/Aufgabenblock_2/Fahrrad.cpp @@ -25,4 +25,3 @@ double Fahrrad::dGeschwindigkeit() const { return dGeschwindigkeit; } - diff --git a/Aufgabenblock_2/Fahrzeug.cpp b/Aufgabenblock_2/Fahrzeug.cpp index 8c669c3..7e30020 100644 --- a/Aufgabenblock_2/Fahrzeug.cpp +++ b/Aufgabenblock_2/Fahrzeug.cpp @@ -6,7 +6,7 @@ #include "Weg.h" #include "FzgFahren.h" #include "FzgParken.h" -#include "AktivesVO.h" +#include "SimuClient.h" extern double dGlobaleZeit; @@ -28,8 +28,7 @@ Fahrzeug::Fahrzeug(string sName, double dMaxGeschwindkeit) : } /* Kopierkonstruktor */ -Fahrzeug::Fahrzeug(Fahrzeug &fz) : - AktivesVO(fz) { +Fahrzeug::Fahrzeug(Fahrzeug &fz) : AktivesVO(fz) { vInitialisierung(); p_dMaxGeschwindigkeit = fz.p_dMaxGeschwindigkeit; } @@ -106,3 +105,7 @@ double Fahrzeug::getAbschnittStrecke() const { bool Fahrzeug::operator<(Fahrzeug &fz) const { return (this->p_dGesamtStrecke < fz.p_dGesamtStrecke); } + +void Fahrzeug::vZeichnen(Weg *pWeg) const { + bZeichneFahrrad(getName(), pWeg->getName(), getAbschnittStrecke() / pWeg->getLaenge(), dGeschwindigkeit()); +} diff --git a/Aufgabenblock_2/Fahrzeug.h b/Aufgabenblock_2/Fahrzeug.h index 4f19a19..8f8f5b5 100644 --- a/Aufgabenblock_2/Fahrzeug.h +++ b/Aufgabenblock_2/Fahrzeug.h @@ -19,6 +19,7 @@ public: virtual void vAbfertigung(); virtual double dTanken(double dMenge = 0.0); + virtual void vZeichnen(Weg *pWeg) const; virtual double dGeschwindigkeit() const; void vNeueStrecke(Weg *pWeg, double dStartZeit = 0.0); diff --git a/Aufgabenblock_2/FzgVerhalten.cpp b/Aufgabenblock_2/FzgVerhalten.cpp index f176b0b..a8ed2b6 100644 --- a/Aufgabenblock_2/FzgVerhalten.cpp +++ b/Aufgabenblock_2/FzgVerhalten.cpp @@ -14,9 +14,9 @@ FzgVerhalten::~FzgVerhalten() double FzgVerhalten::getMaxgeschwindigkeit() { switch (p_pWeg->getLimit()) { - case Innerorts: return 50; - case Landstrasse: return 100; - case Autobahn: return DBL_MAX; /* unbegrenzt */ + case Weg::Innerorts: return 50; + case Weg::Landstrasse: return 100; + case Weg::Autobahn: return DBL_MAX; /* unbegrenzt */ default: return 0; } } diff --git a/Aufgabenblock_2/LazyAktion.h b/Aufgabenblock_2/LazyAktion.h index 0bf5aa3..0f6860b 100644 --- a/Aufgabenblock_2/LazyAktion.h +++ b/Aufgabenblock_2/LazyAktion.h @@ -1,60 +1,84 @@ -/*** LAZYAKTION.H ***/ - -#ifndef __LazyAktion_h -#define __LazyAktion_h +#ifndef LAZYAKTION_H_ +#define LAZYAKTION_H_ #include + using namespace std; // Oberklasse LazyAktion -template -class LazyAktion -{ - public: - LazyAktion( list* ptLazyListe ) - : p_ptLazyListe( ptLazyListe ) {} - virtual ~LazyAktion() {} - virtual void vAusfuehren() = 0; - protected: - list* p_ptLazyListe; // Zeiger auf p_ListeObjekte -}; +template class LazyAktion { +public: + LazyAktion(list *ptLazyListe) : p_ptLazyListe(ptLazyListe) { } + virtual ~LazyAktion() { } + virtual void vAusfuehren() = 0; + +protected: + list *p_ptLazyListe; // Zeiger auf p_ListeObjekte auf die die Aktionen angewendet werden sollen +}; // LazyPushFront -template -class LazyPushFront : public LazyAktion -{ - public: - LazyPushFront(const T& einObjekt, list* eineListe) - : LazyAktion(eineListe) - , p_tObjekt(einObjekt) {} - virtual ~LazyPushFront() {} - void vAusfuehren() { p_ptLazyListe->push_front(p_tObjekt); } - private: - T p_tObjekt; -}; +template class LazyPushFront : public LazyAktion { +public: + LazyPushFront(const T &einObjekt, list *eineListe) : + LazyAktion (eineListe), + p_tObjekt(einObjekt) + { } + + virtual ~LazyPushFront() { } + + void vAusfuehren() { + p_ptLazyListe->push_front(p_tObjekt); + } + +private: + using LazyAktion::p_ptLazyListe; + T p_tObjekt; +}; // LazyPushBack +template class LazyPushBack : public LazyAktion { -... +public: + LazyPushBack(const T &einObjekt, list *eineListe) : + LazyAktion (eineListe), + p_tObjekt(einObjekt) + { } + virtual ~LazyPushBack() { } -// LazyErase -template -class LazyErase : public LazyAktion -{ - // typedef fuer iterator - typedef typename list::iterator iterator; - typedef typename list::const_iterator const_iterator; + void vAusfuehren() { + p_ptLazyListe->push_back(p_tObjekt); + } - public: - LazyErase( ... ) : ... {} - virtual ~LazyErase() {} - void vAusfuehren() { ... } - private: - iterator p_itObjekt; // bei erase Iterator speichern +private: + using LazyAktion::p_ptLazyListe; // für gcc notwendig + T p_tObjekt; }; +template class LazyErase : public LazyAktion { + // typedef für iterator + typedef typename list::iterator iterator; + typedef typename list::const_iterator const_iterator; -#endif \ No newline at end of file +public: + LazyErase(const iterator &itObjekt, list *eineListe) : + LazyAktion (eineListe), + p_itObjekt(itObjekt) + { + cout << "reihe " << *itObjekt << " zur löschung ein" << endl; + } + + virtual ~LazyErase() { } + + void vAusfuehren() { + p_ptLazyListe->erase(p_itObjekt); + } + +private: + using LazyAktion::p_ptLazyListe; // für gcc notwendig + iterator p_itObjekt; // bei erase Iterator speichern +}; + +#endif /* LAZYAKTION_H_ */ diff --git a/Aufgabenblock_2/LazyListe.h b/Aufgabenblock_2/LazyListe.h index 1b3c871..d6a73c9 100644 --- a/Aufgabenblock_2/LazyListe.h +++ b/Aufgabenblock_2/LazyListe.h @@ -1,92 +1,97 @@ -/*** LAZYLISTE.H ***/ - -#ifndef __LazyListe_h -#define __LazyListe_h +#ifndef LAZYLISTE_H_ +#define LAZYLISTE_H_ #include + #include "LazyAktion.h" -template -class LazyListe -{ - public: - // typedef fuer iterator - typedef typename list::iterator iterator; - typedef typename list::const_iterator const_iterator; +using namespace std; - // Konstruktor / Destruktor - LazyListe() { bChanged = false; } - virtual ~LazyListe() - { - if (bChanged) - { - // ggf. noch anstehende Aktionen löschen - do - { - delete *(p_ListeAktionen.begin()); - p_ListeAktionen.pop_front(); - } - while (p_ListeAktionen.size() > 0); - } - } +template class LazyListe { - // Lesefunktionen - const_iterator begin() const {return p_ListeObjekte.begin();} - const_iterator end() const {...} - iterator begin() {return p_ListeObjekte.begin();} - iterator end() {...} - bool empty() const {...} +public: + // typedef für Iterator + typedef typename list::iterator iterator; + typedef typename list::const_iterator const_iterator; - // Schreibfunktionen - void push_back( const T einObjekt ) - { - p_ListeAktionen.push_back(new LazyPushBack(...)); - bChanged = true; - return; - } + // Konstruktor / Destruktor + LazyListe() { + bChanged = false; + } - void push_front( const T einObjekt ) - { - ... + virtual ~LazyListe() { + if (bChanged) { + // ggf. noch anstehende Aktionen löschen + do { + delete *(p_ListeAktionen.begin()); + p_ListeAktionen.pop_front(); + } while (p_ListeAktionen.size() > 0); + } + } - bChanged = true; - return; - } + // Lesefunktionen + const_iterator begin() const { + return p_ListeObjekte.begin(); + } + const_iterator end() const { + return p_ListeObjekte.end(); + } - void erase( iterator itObjekt ) - { - ... + iterator begin() { + return p_ListeObjekte.begin(); + } - bChanged = true; - return; - } + iterator end() { + return p_ListeObjekte.end(); + } - // Änderungen auf Objektliste übertragen - void vAktualisieren() - { - list *>::const_iterator itL; + bool empty() const { + return p_ListeObjekte.empty(); + } - if ( bChanged ) - { - // ausstehende Aktionen durchfuehren - for (itL=... ) - { - // Aktion ausführen - ... - // Zeiger auf Action-Element löschen - ... - } - // Liste der Aktionen leeren - p_ListeAktionen.clear(); + // Schreibfunktionen + void push_back(const T einObjekt) { + p_ListeAktionen.push_back(new LazyPushBack(einObjekt, &p_ListeObjekte)); + bChanged = true; + } - bChanged = false; - } - } + void push_front(const T einObjekt) { + p_ListeAktionen.push_back(new LazyPushFront(einObjekt, &p_ListeObjekte)); + bChanged = true; + } - private: - list p_ListeObjekte; - list*> p_ListeAktionen; - bool bChanged; + void erase(iterator itObjekt) { + p_ListeAktionen.push_back(new LazyErase(itObjekt, &p_ListeObjekte)); + bChanged = true; + } + + // Änderungen auf Objektliste übertragen + void vAktualisieren() { + if (bChanged) { + // ausstehende Aktionen durchfuehren + typename list *>::const_iterator it; // TODO warum typename?! + for (it = p_ListeAktionen.begin(); it != p_ListeAktionen.end(); it++) { + cout << "führe aktion aus, noch " << p_ListeAktionen.size() << endl; + // Aktion ausführen + //LazyAktion *pAktion = *it; + //pAktion->vAusfuehren(); + + (*it)->vAusfuehren(); + + // Zeiger auf Action-Element löschen + delete *it; + } + // Liste der Aktionen leeren + p_ListeAktionen.clear(); + + bChanged = false; + } + } + +private: + list p_ListeObjekte; + list *> p_ListeAktionen; + bool bChanged; }; -#endif \ No newline at end of file +#endif /* LAZYLISTE_H_ */ diff --git a/Aufgabenblock_2/Losfahren.cpp b/Aufgabenblock_2/Losfahren.cpp index 93cd982..1855497 100644 --- a/Aufgabenblock_2/Losfahren.cpp +++ b/Aufgabenblock_2/Losfahren.cpp @@ -11,5 +11,8 @@ Losfahren::~Losfahren() { } void Losfahren::vBearbeiten() { - cout << "Fahrausnahme: Losfahren (Fzg: " << *p_pFahrzeug << ", Weg: " << *p_pWeg << ")" << endl; + cerr << "Fahrausnahme: Losfahren (Fzg: " << *p_pFahrzeug << ", Weg: " << *p_pWeg << ")" << endl; + + p_pWeg->vAbgabe(p_pFahrzeug); + p_pWeg->vAnnahme(p_pFahrzeug); } diff --git a/Aufgabenblock_2/PKW.cpp b/Aufgabenblock_2/PKW.cpp index 869f1ac..c9aceb4 100644 --- a/Aufgabenblock_2/PKW.cpp +++ b/Aufgabenblock_2/PKW.cpp @@ -2,6 +2,7 @@ #include #include "PKW.h" +#include "SimuClient.h" using namespace std; @@ -48,6 +49,10 @@ double PKW::dTanken(double dMenge) { return p_dTankinhalt - dAlterInhalt; } +void PKW::vZeichnen(Weg *pWeg) const { + bZeichnePKW(getName(), pWeg->getName(), getAbschnittStrecke() / pWeg->getLaenge(), dGeschwindigkeit(), getTankinhalt()); +} + void PKW::vAbfertigung() { if (p_dTankinhalt > 0) { /* prüfen, ob etwas im Tank ist */ p_dTankinhalt -= (dGlobaleZeit - p_dZeit) * p_dMaxGeschwindigkeit diff --git a/Aufgabenblock_2/PKW.h b/Aufgabenblock_2/PKW.h index f9af0b3..416b039 100644 --- a/Aufgabenblock_2/PKW.h +++ b/Aufgabenblock_2/PKW.h @@ -25,6 +25,7 @@ public: ostream& ostreamAusgabe(ostream &stream) const; double dVerbrauch() const; double dTanken(double dMenge = 0.0); + void vZeichnen(Weg *pWeg) const; double getTankinhalt() const; private: diff --git a/Aufgabenblock_2/Streckenende.cpp b/Aufgabenblock_2/Streckenende.cpp index 4d21e8e..1018a6e 100644 --- a/Aufgabenblock_2/Streckenende.cpp +++ b/Aufgabenblock_2/Streckenende.cpp @@ -11,5 +11,7 @@ Streckenende::~Streckenende() { } void Streckenende::vBearbeiten() { - cout << "Fahrausnahme: Streckenende (Fzg: " << *p_pFahrzeug << ", Weg: " << *p_pWeg << ")" << endl; + cerr << "Fahrausnahme: Streckenende (Fzg: " << *p_pFahrzeug << ", Weg: " << *p_pWeg << ")" << endl; + + p_pWeg->vAbgabe(p_pFahrzeug); } diff --git a/Aufgabenblock_2/Weg.cpp b/Aufgabenblock_2/Weg.cpp index f1117a5..4ad2eac 100644 --- a/Aufgabenblock_2/Weg.cpp +++ b/Aufgabenblock_2/Weg.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "Weg.h" #include "Fahrzeug.h" @@ -22,18 +23,17 @@ Weg::~Weg() /* fertige alle Fahrzeuge auf Weg ab */ void Weg::vAbfertigung() { - list::const_iterator iterator; + list::iterator it; - for (iterator = p_pFahrzeuge.begin(); iterator != p_pFahrzeuge.end(); ++iterator) { + for (it = p_pFahrzeuge.begin(); it != p_pFahrzeuge.end(); it++) { try { - (*iterator)->vAbfertigung(); + (*it)->vAbfertigung(); } catch (FahrAusnahme &ausnahme) { ausnahme.vBearbeiten(); } } p_dZeit = dGlobaleZeit; - } void Weg::vAnnahme(Fahrzeug *pFz, double dStartZeit) { @@ -41,11 +41,21 @@ void Weg::vAnnahme(Fahrzeug *pFz, double dStartZeit) { p_pFahrzeuge.push_back(pFz); } +void Weg::vAbgabe(Fahrzeug *pFz) { + list::iterator result; + + result = find(p_pFahrzeuge.begin(), p_pFahrzeuge.end(), pFz); + + if (result != p_pFahrzeuge.end()) { + p_pFahrzeuge.erase(result); + } +} + double Weg::getLaenge() const { return p_dLaenge; } -Begrenzung Weg::getLimit() const { +Weg::Begrenzung Weg::getLimit() const { return p_eLimit; } @@ -54,9 +64,9 @@ ostream& Weg::ostreamAusgabe(ostream &stream) const { << resetiosflags(ios::left) << setiosflags(ios::right) << setw(24) << p_dLaenge << " ( "; - list::const_iterator iterator; - for (iterator = p_pFahrzeuge.begin(); iterator != p_pFahrzeuge.end(); ++iterator) { - stream << (*iterator)->getName() << " "; + list::const_iterator it; + for (it = p_pFahrzeuge.begin(); it != p_pFahrzeuge.end(); it++) { + stream << (*it)->getName() << " "; } stream << ")"; diff --git a/Aufgabenblock_2/Weg.h b/Aufgabenblock_2/Weg.h index af39647..1a60da7 100644 --- a/Aufgabenblock_2/Weg.h +++ b/Aufgabenblock_2/Weg.h @@ -10,20 +10,22 @@ using namespace std; class Fahrzeug; /* Forward Deklaration */ -typedef enum { - Innerorts, /* 50 km/h */ - Landstrasse, /* 100 km/h */ - Autobahn /* unbegrenzt */ -} Begrenzung; - class Weg : public AktivesVO { public: + typedef enum { + Innerorts, /* 50 km/h */ + Landstrasse, /* 100 km/h */ + Autobahn /* unbegrenzt */ + } Begrenzung; + Weg(); Weg(string sName, double dLaenge, Begrenzung eLimit = Autobahn); virtual ~Weg(); void vAbfertigung(); void vAnnahme(Fahrzeug *pFz, double dStartZeit = 0); + void vAbgabe(Fahrzeug *pFz); + double getLaenge() const; Begrenzung getLimit() const; diff --git a/Aufgabenblock_2/main.cpp b/Aufgabenblock_2/main.cpp index 8adfed9..ec8508e 100644 --- a/Aufgabenblock_2/main.cpp +++ b/Aufgabenblock_2/main.cpp @@ -1,12 +1,14 @@ #include #include #include +#include #include "SimuClient.h" #include "Fahrzeug.h" #include "Fahrrad.h" #include "PKW.h" #include "Weg.h" +#include "LazyListe.h" using namespace std; @@ -152,7 +154,7 @@ void vAufgabe3() { } void vAufgabe4() { - Weg weg("Allee", 150.0, Landstrasse); + Weg weg("Allee", 150.0, Weg::Landstrasse); PKW vw("Golf", 110, 6.7, 88); Fahrrad velo("Haibike", 22); @@ -168,8 +170,8 @@ void vAufgabe4() { } void vAufgabe5() { - Weg hin("Hinweg", 500.0, Landstrasse); - Weg rueck("Rueckweg", 500.0, Landstrasse); + Weg hin("Hinweg", 500.0, Weg::Landstrasse); + Weg rueck("Rueckweg", 500.0, Weg::Landstrasse); PKW vw("Golf", 110, 6.7, 88); Fahrrad velo("Haibike", 22); @@ -192,8 +194,9 @@ void vAufgabe5() { rueck.vAbfertigung(); vSetzeZeit(dGlobaleZeit); - bZeichnePKW(vw.getName(), hin.getName(), vw.getAbschnittStrecke() / hin.getLaenge(), vw.dGeschwindigkeit(), vw.getTankinhalt()); - bZeichneFahrrad(velo.getName(), rueck.getName(), velo.getAbschnittStrecke() / hin.getLaenge(), velo.dGeschwindigkeit()); + + vw.vZeichnen(&hin); + velo.vZeichnen(&rueck); cout << vw << endl << velo << endl << hin << endl << rueck << endl; @@ -203,33 +206,119 @@ void vAufgabe5() { vBeendeGrafik(); } +void vAufgabe6() { + Weg weg("Allee", 300.0, Weg::Landstrasse); + PKW vw("Golf", 110, 6.7, 88); + + weg.vAnnahme(&vw); + + Fahrzeug::vAusgabeHeader(); + while (dGlobaleZeit < 10) { + dGlobaleZeit += 0.5; + weg.vAbfertigung(); + cout << vw << endl << weg << endl; + } +} + +void vListeAusgeben(LazyListe tListe) { + LazyListe::iterator it; + for (it = tListe.begin(); it != tListe.end(); it++) { + cout << *it << ", "; + } + cout << endl; +} + +void vAufgabe6a() { + LazyListe tListe; + LazyListe::iterator it; + + /* PRNG mit konstantem seed initialisieren */ + srand(55); + + /* Mit Zufallszahlen füllen */ + cout << "Fülle mit Zufallszahlen" << endl; + for (int i = 0; i < 10; i++) { + tListe.push_back(rand() % 10 + 1); + } + + cout << "Führe LazyAktionen aus" << endl; + tListe.vAktualisieren(); + + cout << "Gebe Liste aus: "; + vListeAusgeben(tListe); + + cout << "Lösche Werte > 5..." << endl; + for (it = tListe.begin(); it != tListe.end(); it++) { + if (*it > 5) { + tListe.erase(it); + } + } + + cout << "Gebe Liste aus: "; + vListeAusgeben(tListe); + + cout << "Führe LazyAktionen aus" << endl; + tListe.vAktualisieren(); + + cout << "Gebe Liste aus: "; + vListeAusgeben(tListe); + + cout << "Weitere Änderungen..." << endl; + tListe.push_front(44); + tListe.push_back(33); + + cout << "Führe LazyAktionen aus" << endl; + tListe.vAktualisieren(); + + cout << "Gebe Liste aus: "; + vListeAusgeben(tListe); +} + +typedef void (*aufgabe_t)(void); +#define NUM_AUFGABEN 7 + int main() { int iWahl; + aufgabe_t pAufgaben[] = { + &vAufgabe1_deb, + &vAufgabe1, + &vAufgabe2, + &vAufgabe3, + &vAufgabe4, + &vAufgabe5, + &vAufgabe6, + &vAufgabe6a + }; + retry: - cout << "1: vAufgabe1()" << endl; cout << "0: vAufgabe1_deb()" << endl; + cout << "1: vAufgabe1()" << endl; cout << "2: vAufgabe2()" << endl; cout << "3: vAufgabe3()" << endl; cout << "4: vAufgabe4()" << endl; cout << "5: vAufgabe5()" << endl; + cout << "6: vAufgabe6()" << endl; + cout << "7: vAufgabe6a()" << endl; cout << "Bitte wähen Sie eine Aufgabe: "; cin >> iWahl; cout << endl; - switch (iWahl) { - case 1: vAufgabe1(); break; - case 0: vAufgabe1_deb(); break; - case 2: vAufgabe2(); break; - case 3: vAufgabe3(); break; - case 4: vAufgabe4(); break; - case 5: vAufgabe5(); break; - default: - cerr << "Ungültige Eingabe! Bitte versuchen Sie es erneut" << endl; - goto retry; + if (iWahl > NUM_AUFGABEN || iWahl < 0) { + cerr << "Ungültige Eingabe! Bitte versuchen Sie es erneut" << endl; + goto retry; } + pAufgaben[iWahl](); /* Funktionspointer aufrufen */ + + cout << endl << endl << "Nochmal? (0/1): "; + cin >> iWahl; cout << endl; + + if (iWahl) { + goto retry; + } + return 0; }