-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap.h
More file actions
45 lines (36 loc) · 1.16 KB
/
map.h
File metadata and controls
45 lines (36 loc) · 1.16 KB
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
#ifndef MAP_H
#define MAP_H
#include <string>
#include <iostream>
#include "util.h"
const int MAX_SIZE = 10;
class Map{
private:
Pos startpos_;
Pos endpos_;
int n_of_rows_;
int n_of_columns_;
public:
std::string map_[MAX_SIZE];
Map(){};
void setStartPos (Pos startpos) { startpos_ = startpos; }
void setEndPos (Pos endpos) { endpos_ = endpos; }
void setNofRows (int index) { n_of_rows_ = index; }
void setNofColumns (int index) { n_of_columns_= index; }
bool isEnd (Pos position) { return ((position.x == endpos_.x) && (position.y == endpos_.y)); }
bool isStart (Pos position) { return ((position.x == startpos_.x) && (position.y == startpos_.y)); }
bool isValid (Pos position) {
if (map_[position.x].at(position.y) == '#') { return false; }
return ((map_[position.x].at(position.y) == '.') || (map_[position.x].at(position.y) == 'x') || map_[position.x].at(position.y) == '@' );
}
int getNofRows() { return n_of_rows_; }
int getNofColumns() { return n_of_columns_; }
Pos getStartPos() { return startpos_; }
Pos getEndPos() { return endpos_; }
void printMap(){
for (int j=0 ; j < n_of_rows_ ; ++j){
std::cout << map_[j] << std::endl;
}
}
};
#endif