-
Notifications
You must be signed in to change notification settings - Fork 0
/
Point.h
101 lines (80 loc) · 1.86 KB
/
Point.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
/*****************************
* Project part B of:
* Ori Kopel 205533151
* Shlomo Rabinovich 308432517
* Januar 2019
******************************/
#ifndef NEWPROJ_POINT_H
#define NEWPROJ_POINT_H
#include "State.h"
#include <stdio.h>
#include <iostream>
using std::ostream;
using std::to_string;
using std::string;
using std::cout;
using std::endl;
class Point : public State<int> {
int x;
int y;
// int cost;
Point *cameFrom;
public:
Point(int x, int y, int cost) : State(cost), x(x), y(y) {
State::cameFrom = nullptr;
this->cameFrom = nullptr;
}
Point *getCameFrom() const {
return cameFrom;
}
void setCameFrom(Point *cameFrom) {
Point::cameFrom = cameFrom;
State::cameFrom = cameFrom;
}
bool equal(Point *other) {
if (other == nullptr) {
return false;
}
return this->operator==(other);
}
bool operator==(Point *other) {
if (other == nullptr) {
return false;
}
return this->operator==(*other);
}
bool operator==(Point other) {
return (this->x == other.getX()) && (this->y == other.getY());
}
int getX() const {
return x;
}
void setX(int x) {
Point::x = x;
}
int getY() const {
return y;
}
void setY(int y) {
Point::y = y;
}
int getCost() const {
return State::state;
}
void setCost(int cost) {
State::setState(cost);
}
string printIndex() {
return "(" + to_string(this->x) + "," + to_string(this->y) + ")";
}
string print() {
return to_string(this->getCost());
}
void costPlus(int num) {
State::setState(this->getCost() + num);
}
void costMinus(int num) {
State::setState(this->getCost() - num);
}
};
#endif //NEWPROJ_POINT_H