-
Notifications
You must be signed in to change notification settings - Fork 0
/
State.h
105 lines (77 loc) · 1.85 KB
/
State.h
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef BIUPROJECT2_STATE_H
#define BIUPROJECT2_STATE_H
/**
* Define's a State.
* @tparam T The state of the State.
*/
template <class T>
class State {
private:
//// Data Members.
int distance_from_start;
double total_cost_to;
double original_cost;
State<T>* cameFrom;
bool visited;
double cost;
T state;
public:
//// CONSTRUCTORS
State (T status, double costTo, State<T>* prev) {
this->state = status;
this->cost = costTo;
this->cameFrom = prev;
this->visited = false;
this->original_cost = costTo;
this->distance_from_start = 0;
this->total_cost_to = costTo;
}
//// CHECKERS
bool Equals(const State<T>* s) {
return this->state == (s->state);
}
//// SETTERS
void setDistance_from_start(int distance_from_start) {
this->distance_from_start = distance_from_start;
}
void setCost(double costTo) {
this->cost = costTo;
}
void setCameFrom(State<T>* prev) {
this->cameFrom = prev;
}
void setVisited(bool val) {
this->visited = val;
}
void setTotal_cost_to(double total_cost_to) {
State::total_cost_to = total_cost_to;
}
//// GETTERS
T getState() const {
return this->state;
}
double getCost() const {
return this->cost;
}
State<T>* getCameFrom() const {
return cameFrom;
}
bool getVisited() const {
return this->visited;
}
bool isVisited() const {
return visited;
}
double getOriginal_cost() const {
return original_cost;
}
int getDistance_from_start() const {
return distance_from_start;
}
double getTotal_cost_to() const {
return total_cost_to;
}
//// DESTRUCTOR
~State(){};
};
#endif //BIUPROJECT2_STATE_H