|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectgameLogic.Position
public class Position
Represents a coordinate (x and y position) on the game board. All methods requiring coordinates as a parameter should be called using a Position object.
Constructor Summary | |
---|---|
Position(int x,
int y)
Constructs a Position object with the given coordinates. |
|
Position(Position position)
|
Method Summary | |
---|---|
boolean |
equals(java.lang.Object other)
|
int |
getDistanceTo(Position other)
Calculates the manhattan distance (the number of squares that must be traversed) between this Position and another Position. |
java.util.List<Position> |
getNeighbours()
Get a list of all neighbours to this position. |
int |
getX()
Gets the X coordinate of this position object. |
int |
getY()
Gets the Y coordinate of this position object. |
int |
hashCode()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Position(int x, int y)
x
- The x coordinate.y
- The y coordinate.public Position(Position position)
Method Detail |
---|
public int getX()
public int getY()
public java.util.List<Position> getNeighbours()
public int getDistanceTo(Position other)
other
- The Position to measure distance to.
public int hashCode()
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |