-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcell.cpp
More file actions
85 lines (56 loc) · 1.69 KB
/
Copy pathcell.cpp
File metadata and controls
85 lines (56 loc) · 1.69 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
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
/*
* Project name: Food collection
* Version 4
* Student : Albert Eduard Merino Pulido
*/
#include "cell.h"
using namespace std;
// Constructors
Cell::Cell(){ }
Cell::Cell(float x, float y, CellType cellType){
this->x = x;
this->y = y;
this->cellType = cellType;
visited = false;
up = NULL;
down = NULL;
left = NULL;
right = NULL;
}
bool Cell::operator == (Cell * c){
return getX() == c->getX() && getY() == c->getY();
}
// Getters
float Cell::getX(){ return x; }
float Cell::getY(){ return y; }
float Cell::getKey(){ return getX() * 100 + getY(); }
bool Cell::isVisited(){ return visited; }
Cell * Cell::getUp(){ return up; }
Cell * Cell::getDown(){ return down; }
Cell * Cell::getLeft(){ return left; }
Cell * Cell::getRight(){ return right; }
CellType Cell::getType(){ return cellType; }
char Cell::getSymbol(){
Drawer& drawer = Drawer::getInstance();
return drawer.getProperties(cellType).symbol;
}
// Setters
void Cell::setX(float x){ this->x = x; }
void Cell::setY(float y){ this->y = y; }
void Cell::setVisited(bool b){ visited = b; }
void Cell::setUp(Cell * c){ up = c; }
void Cell::setDown(Cell * c){ down = c; }
void Cell::setLeft(Cell * c){ left = c; }
void Cell::setRight(Cell * c){ right = c; }
void Cell::setCellType(CellType cellType){
this->cellType = cellType;
}
// Print
void Cell::print(){ cout << getX() << " " << getY() << endl; }
bool Cell::hasFood(){ return cellType == FOOD; }
bool Cell::isWall(){ return cellType == WALL; }
bool Cell::isCorridor(){ return cellType == CORRIDOR; }
void Cell::draw(){
Drawer& drawer = Drawer::getInstance();
drawer.draw(getType(), getX(), getY(), false);
}