-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPosition.h
More file actions
38 lines (28 loc) · 814 Bytes
/
Position.h
File metadata and controls
38 lines (28 loc) · 814 Bytes
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
#ifndef __POSITION_H__
#define __POSITION_H__
namespace df{
class Position {
private:
int x; // Horizontal coordinate in 2d world.
int y; // Vertical coordinate in 2d world.
public:
// Create object at 2d location (x,y).
Position(int init_x, int init_y);
// Default 2d (x,y) location is (0,0).
Position();
// Get/set horizontal coordinate.
void setX(int new_x);
int getX() const;
// Get/set vertical coordinate.
void setY(int new_y);
int getY() const;
// Set horizontal & vertical coordinates.
void setXY(int new_x, int new_y);
// returns if positions are equal or not
bool equalTo(df::Position pos);
// get the manhattan distance of the positions
int getManhattanDistance(df::Position pos);
df::Position getNextAdjacentPosition(df::Position to);
};
}
#endif