-
Notifications
You must be signed in to change notification settings - Fork 0
/
Labyrinth.cpp
86 lines (73 loc) · 2.06 KB
/
Labyrinth.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include "Labyrinth.hpp"
unsigned int Labyrinth::getHeight() const {
return height;
}
void Labyrinth::setHeight(unsigned int height) {
Labyrinth::height = height;
}
unsigned int Labyrinth::getWidth() const {
return width;
}
void Labyrinth::setWidth(unsigned int width) {
Labyrinth::width = width;
}
const Coordinate &Labyrinth::getStartPoint() const {
return startPoint;
}
void Labyrinth::setStartPoint(const Coordinate &startPoint) {
Labyrinth::startPoint = startPoint;
}
const Coordinate &Labyrinth::getEndPoint() const {
return endPoint;
}
void Labyrinth::setEndPoint(const Coordinate &endPoint) {
Labyrinth::endPoint = endPoint;
}
Coordinate &Labyrinth::at(Coordinate &coordinate) {
unsigned int x = coordinate.getX();
unsigned int y = coordinate.getY();
return at(x, y);
}
Coordinate & Labyrinth::at(unsigned int x, unsigned int y) {
return map.at(x).at(y);
}
const Coordinate & Labyrinth::at(unsigned int x, unsigned int y) const {
return map.at(x).at(y);
}
void Labyrinth::setMap(vector<vector<Coordinate>> &map) {
this->map = map;
}
ostream &operator<<(ostream &os, const Labyrinth &labyrinth) {
string fields = " ";
const Coordinate *coordinate = nullptr; //Coordinate wird dem Nullpointer zugeordnet
/* Spalteniteration
for (unsigned int x = 0; x < labyrinth.getWidth(); ++x) {
fields+= std::to_string(x);
}
*/
fields += "\n";
for (unsigned int y = 0; y < labyrinth.getHeight(); ++y) { //Zeileniteration
//fields += std::to_string(y); //Debug
for (unsigned int x = 0; x < labyrinth.getWidth(); ++x) {
coordinate = &labyrinth.at(x,y);
if(coordinate->isWalkable())
{
if(coordinate->isUsedPath())
{
fields += ".";
}
else
{
fields += " ";
}
}
else
{
fields += "*";
}
}
fields += "\n";
}
os << fields;
return os;
}