-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f651b83
Showing
49 changed files
with
4,363 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 3.7) | ||
project(Parkhaus) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
|
||
set(SOURCE_FILES main.cpp Stellplatz.cpp Parkhaus.cpp) | ||
add_executable(Parkhaus ${SOURCE_FILES}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#include"Parkhaus.h" | ||
|
||
|
||
Parkhaus::Parkhaus(string s, vector<Stellplatz> v) : adresse(s), v(v) { | ||
if (s == "") throw runtime_error("error adresse"); | ||
} | ||
|
||
|
||
vector<Stellplatz> Parkhaus::finde(Ptyp typ) const { | ||
|
||
vector<Stellplatz> vv; | ||
for (int i = 0; i < v.size(); ++i) { | ||
if (v[i].passt(typ) && v[i].ist_frei()) { | ||
vv.push_back(v[i]); | ||
} | ||
} | ||
return vv; | ||
|
||
} | ||
|
||
bool Parkhaus::einfahren(Ptyp typ) { | ||
for (int i = 0; i < v.size(); ++i) { | ||
if (v[i].ist_frei() && v[i].passt(typ)) { | ||
v[i].einparken(typ); | ||
return true; | ||
} | ||
|
||
} | ||
return false; | ||
|
||
} | ||
|
||
void Parkhaus::ausfahren(size_t no) { | ||
if (v.size() < no) throw runtime_error("error 80"); | ||
// if(v[no].ist_frei()) throw runtime_error ("error 80"); | ||
v[no].ausparken(); | ||
|
||
} | ||
|
||
|
||
ostream &operator<<(ostream &o, const Parkhaus &s) { | ||
return s.print(o); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef PARKHAUS_H | ||
#define PARKHAUS_H | ||
|
||
#include"Stellplatz.h" | ||
|
||
#include<iostream> | ||
#include<vector> | ||
#include<string> | ||
#include<stdexcept> | ||
|
||
using namespace std; | ||
|
||
|
||
class Parkhaus { | ||
string adresse; | ||
vector<Stellplatz> v; | ||
public: | ||
Parkhaus(string, vector<Stellplatz>); | ||
|
||
vector<Stellplatz> finde(Ptyp typ) const; | ||
bool einfahren(Ptyp typ); | ||
void ausfahren(size_t no); | ||
|
||
ostream &print(ostream &o) const{ | ||
o << "[" << adresse << "{"; | ||
|
||
for (int i = 0; i < v.size(); ++i) { | ||
o << v[i]; | ||
if (i != v.size()-1) o << ", "; | ||
} | ||
|
||
return o << "}]"; | ||
} | ||
|
||
|
||
}; | ||
|
||
ostream &operator<<(ostream &o, const Parkhaus &s); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include"Stellplatz.h" | ||
|
||
Stellplatz::Stellplatz(Ptyp t){ | ||
ptyp = t; | ||
frei = true; | ||
} | ||
|
||
//ostream& Stellplatz::print(ostream &o) const { | ||
// o << "["; | ||
// if (ptyp == Ptyp::pkw) o << "PKW"; | ||
// if (ptyp == Ptyp::bus) o << "BUS"; | ||
// if (ptyp == Ptyp::krad) o << "2RAD"; | ||
// | ||
// if (frei == false) o << " belegt"; | ||
// | ||
// return o << "]"; | ||
//} | ||
|
||
ostream& operator<< (ostream& o, const Stellplatz& s) { | ||
return s.print(o); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#ifndef STELLPLATZ_H | ||
#define STELLPLATZ_H | ||
|
||
#include<iostream> | ||
#include<stdexcept> | ||
|
||
using namespace std; | ||
|
||
enum class Ptyp { | ||
pkw, bus, krad | ||
}; | ||
|
||
class Stellplatz { | ||
Ptyp ptyp; | ||
bool frei; | ||
public: | ||
|
||
Stellplatz(Ptyp t = Ptyp::pkw); | ||
|
||
bool ist_frei() const { return frei; } | ||
|
||
bool passt(Ptyp typ) const { | ||
if (typ == ptyp) return true; | ||
else return false; | ||
} | ||
|
||
bool einparken(Ptyp typ) { | ||
|
||
if (passt(typ) && ist_frei()) { | ||
frei = false; | ||
return true; | ||
|
||
} else return false; | ||
|
||
} | ||
|
||
void ausparken() { | ||
if (frei == true) throw runtime_error("error 2"); | ||
else frei = true; | ||
} | ||
|
||
|
||
|
||
|
||
ostream &print(ostream &o) const { | ||
o << "["; | ||
if (ptyp == Ptyp::pkw) o << "PKW"; | ||
if (ptyp == Ptyp::bus) o << "BUS"; | ||
if (ptyp == Ptyp::krad) o << "2RAD"; | ||
|
||
if (frei == false) o << " belegt"; | ||
|
||
return o << "]"; | ||
} | ||
|
||
}; | ||
|
||
ostream& operator<< (ostream& o, const Stellplatz& s); | ||
|
||
|
||
#endif |
Oops, something went wrong.