Class Position
- java.lang.Object
-
- de.unistuttgart.informatik.fius.icge.simulation.Position
-
public class Position extends Object
Represents a position on the playfield.Objects of this class are immutable
x is the row; negative towards the top (
Direction.NORTH
) and positive towards the bottom (Direction.SOUTH
)y is the column; negative towards the left (
Direction.WEST
) and positive towards the right (Direction.EAST
)- Author:
- Tim Neumann
- See Also:
Direction
-
-
Constructor Summary
Constructors Constructor Description Position(int x, int y)
Create a new position from the given parameters.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Position
adjacentPosition(Direction direction)
Get the adjacent position in the given direction.boolean
equals(Object o)
int
getX()
int
getY()
int
hashCode()
String
toString()
-
-
-
Method Detail
-
getX
public int getX()
- Returns:
- the x coordinate of this position
-
getY
public int getY()
- Returns:
- the y coordinate of this position
-
adjacentPosition
public Position adjacentPosition(Direction direction)
Get the adjacent position in the given direction.- Parameters:
direction
- The direction to get the adjacent position in- Returns:
- The position adjacent to this in the given direction
-
-