-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzone.cpp
More file actions
81 lines (69 loc) · 1.68 KB
/
zone.cpp
File metadata and controls
81 lines (69 loc) · 1.68 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
//Author: Nathan Jodoin
//CSCE2110 SimCity
//Recitation Sec. 213 Group 6
//zone class definition
#include "definitions.hpp"
class zone
{
private:
std::pair<int,int> location;
int pollution;
bool powered;
//local adjacency list, should be reserved size 8 in constructor
std::vector<zone*> locallyAdjacent;
public:
//constructor
zone()
{
//if a zone has -1, -1 after intiialization, the location hasn't been set correctly
location = std::pair<int,int>(-1,-1);
pollution = 0;
powered = false;
//reserve 8 spots for the local adjacencies
this->locallyAdjacent.reserve(8);
}
zone(int x_loc, int y_loc)
{
location = std::pair<int,int>(x_loc, y_loc);
pollution = 0;
powered = false;
this->locallyAdjacent.reserve(8);
}
//Accessors
virtual char getType()
{
return ' ';
}
std::pair<int,int> getLocation() const
{
return this->location;
}
int getPollution() const
{
return this->pollution;
}
bool isPowered() const{
return this->powered;
}
std::vector<zone*> getLocallyAdjacent() const
{
return this->locallyAdjacent;
}
//MUTATORS
void setLocation(int X, int Y)
{
this->location.first = X;
this->location.second = Y;
}
void setPollution(int pollutionVal)
{
this->pollution = pollutionVal;
}
void setPowered(bool isPoweredOrNot){
this->powered = isPoweredOrNot;
}
void setLocallyAdjacent(std::vector<zone*> locallyAdjacentNodes){
//remember this must be size 8, top left adjacent first
this->locallyAdjacent = locallyAdjacentNodes;
}
};