Umlautcodierung behoben und vieles mehr
This commit is contained in:
parent
24a2fb4b95
commit
b1b9847e10
7 changed files with 34 additions and 20 deletions
|
@ -32,7 +32,7 @@ AktivesVO::~AktivesVO() {
|
|||
void AktivesVO::vRegister() {
|
||||
map<string, AktivesVO*>::iterator result = p_pObjekte.find(p_sName);
|
||||
if (result != p_pObjekte.end()) {
|
||||
throw string("Ein Objekt mit dem Namen existiert bereits!");
|
||||
throw string("Ein Objekt mit dem Namen existiert bereits! ") + p_sName;
|
||||
}
|
||||
|
||||
p_pObjekte[p_sName] = this;
|
||||
|
|
|
@ -44,10 +44,10 @@ void Kreuzung::vTanken(Fahrzeug *pFz) {
|
|||
|
||||
void Kreuzung::vAnnahme(Fahrzeug *pFz, double dStartZeit, Weg *pNeuerWeg) {
|
||||
if (pNeuerWeg != NULL) {
|
||||
pNeuerWeg->vAnnahme(pFz, dStartZeit);
|
||||
pZufaelligerWeg()->vAnnahme(pFz, dStartZeit);
|
||||
}
|
||||
else {
|
||||
p_lWege.front()->vAnnahme(pFz, dStartZeit);
|
||||
pZufaelligerWeg()->vAnnahme(pFz, dStartZeit);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,6 +105,10 @@ istream& Kreuzung::istreamEingabe(istream &stream) {
|
|||
Weg * Kreuzung::pZufaelligerWeg(Weg *pAlterWeg) {
|
||||
Weg *pZufallWeg = NULL;
|
||||
|
||||
if (p_lWege.size() == 1) {
|
||||
return p_lWege.front();
|
||||
}
|
||||
|
||||
do {
|
||||
list<Weg *>::iterator it;
|
||||
int iZufall = rand() % p_lWege.size();
|
||||
|
@ -115,7 +119,7 @@ Weg * Kreuzung::pZufaelligerWeg(Weg *pAlterWeg) {
|
|||
|
||||
if (i++ >= iZufall) break;
|
||||
}
|
||||
} while (pZufallWeg == pAlterWeg->getRueckweg() && p_lWege.size() > 1);
|
||||
} while (pAlterWeg && pZufallWeg == pAlterWeg->getRueckweg());
|
||||
|
||||
return pZufallWeg;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
void vAbfertigung();
|
||||
void vZeichnen() const;
|
||||
void vZeichnen(Koordinaten iKoordinaten) const;
|
||||
Weg * pZufaelligerWeg(Weg *pAlterWeg);
|
||||
Weg * pZufaelligerWeg(Weg *pAlterWeg = NULL);
|
||||
|
||||
double getTankinhalt();
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* SimuClient für MacOS/Linux (Praktikum Informatik 2, WS 2009/10 RWTH Aachen)
|
||||
* SimuClient für MacOS/Linux (Praktikum Informatik 2, WS 2009/10 RWTH Aachen)
|
||||
* Version 0.5
|
||||
* von Robert Uhl, 2009 - 2010
|
||||
* Vielen Dank an den Lehrstuhl EECS, RWTH Aachen, für den Zugang zum Quellcode
|
||||
* des SimuClient für Windows.
|
||||
* Vielen Dank an den Lehrstuhl EECS, RWTH Aachen, für den Zugang zum Quellcode
|
||||
* des SimuClient für Windows.
|
||||
* Datei: SimuClient.h
|
||||
* Inhalt: SimuClient sendet Daten an den (erweiterten) Java-Grafik-Server
|
||||
*/
|
||||
|
@ -14,6 +14,15 @@
|
|||
#include <string>
|
||||
using namespace std;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
int x, y;
|
||||
};
|
||||
struct {
|
||||
int width, height;
|
||||
};
|
||||
} Koordinaten;
|
||||
|
||||
// Funktionen der Library
|
||||
bool bInitialisiereGrafik(int sizeX, int sizeY, bool bStarteServer = true, const string& sServer = "localhost", const unsigned short iPort = 7654);
|
||||
bool bZeichneKreuzung(int posX, int posY);
|
||||
|
@ -21,10 +30,10 @@ bool bZeichneStrasse(const string& way_to_name, const string& way_back_name, int
|
|||
bool bZeichnePKW(const string& carname, const string& streetname, double rel_position, double speed, double tank);
|
||||
bool bZeichneFahrrad(const string& bikename, const string& streetname, double relposition, double speed);
|
||||
void vSetzeZeit(const double dTime); // sendet die Simulationszeit an den erweiterten Grafikserver
|
||||
void Sleep(const int mSec); // ersetzt die Sleep()-Funktion von Windows, die mSek übernimmt
|
||||
void Sleep(const int mSec); // ersetzt die Sleep()-Funktion von Windows, die mSek übernimmt
|
||||
void vBeendeGrafik(void);
|
||||
|
||||
// Zusätzliche Schnittstellen wegen eventueller Konvertierungsprobleme bei string/char*
|
||||
// Zusätzliche Schnittstellen wegen eventueller Konvertierungsprobleme bei string/char*
|
||||
bool bZeichneStrasse(const char* way_to_name, const char* way_back_name, int length, int numPoints, int* points_xy);
|
||||
bool bZeichneStrasse(const string& way_to_name, const char* way_back_name, int length, int numPoints, int* points_xy);
|
||||
bool bZeichneStrasse(const char* way_to_name, const string& way_back_name, int length, int numPoints, int* points_xy);
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
typedef enum {
|
||||
Innerorts = 1, /* 50 km/h */
|
||||
Landstrasse, /* 100 km/h */
|
||||
Autobahn /* unbegrenzt */
|
||||
Autobahn /* unbegrenzt */
|
||||
} Begrenzung;
|
||||
|
||||
Weg();
|
||||
|
|
|
@ -113,7 +113,7 @@ void Welt::vEinlesenMitGrafik(istream &in) {
|
|||
Koordinaten iPos;
|
||||
in >> *pKr >> iPos.x >> iPos.y;
|
||||
|
||||
pKr->vZeichnen(iPos);
|
||||
//pKr->vZeichnen(iPos);
|
||||
p_pKreuzungen.push_back(pKr);
|
||||
}
|
||||
else if (sTyp == "STRASSE") {
|
||||
|
|
|
@ -433,11 +433,6 @@ void vAufgabe9(int argc, char *argv[]) {
|
|||
PKW pkw2(sName, 99);
|
||||
}
|
||||
|
||||
void vParseOSM(int argc, char *argv[]) {
|
||||
TiXmlDocument doc( "demo.xml" );
|
||||
doc.LoadFile();
|
||||
}
|
||||
|
||||
void vAufgabe9a(int argc, char *argv[]) {
|
||||
ifstream File;
|
||||
|
||||
|
@ -450,12 +445,15 @@ void vAufgabe9a(int argc, char *argv[]) {
|
|||
throw string("Datei existiert nicht!");
|
||||
}
|
||||
|
||||
bInitialisiereGrafik(1000, 900);
|
||||
bInitialisiereGrafik(1000, 1000);
|
||||
|
||||
Welt tErde;
|
||||
tErde.vEinlesenMitGrafik(File);
|
||||
|
||||
for (dGlobaleZeit = 0; dGlobaleZeit < 24*31; dGlobaleZeit += 0.01) {
|
||||
double dInterval = 5.0/60; /* in Stunden */
|
||||
double dRatio = 500;
|
||||
|
||||
for (dGlobaleZeit = 0; dGlobaleZeit < 24; dGlobaleZeit += dInterval) {
|
||||
tErde.vAbfertigung();
|
||||
tErde.vZeichnen();
|
||||
|
||||
|
@ -463,7 +461,7 @@ void vAufgabe9a(int argc, char *argv[]) {
|
|||
//cout << tErde << "--" << endl;
|
||||
|
||||
vSetzeZeit(dGlobaleZeit);
|
||||
Sleep(40);
|
||||
Sleep(60*60 * dInterval * 1000 / dRatio); /* in ms */
|
||||
}
|
||||
|
||||
vBeendeGrafik();
|
||||
|
@ -476,6 +474,9 @@ int main(int argc, char *argv[]) {
|
|||
/* PRNG mit konstantem seed initialisieren */
|
||||
srand(55);
|
||||
|
||||
vAufgabe9a(argc, argv);
|
||||
return 0; /* skip the rest */
|
||||
|
||||
int iWahl;
|
||||
|
||||
aufgabe_t pAufgaben[] = {
|
||||
|
|
Loading…
Add table
Reference in a new issue