public class Location
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
int |
x
x-coordinate of this location.
|
int |
y
y-coordinate of this location.
|
| Constructor and Description |
|---|
Location()
Empty constructor.
|
Location(int x_,
int y_)
Constructor of a new Location.
|
| Modifier and Type | Method and Description |
|---|---|
Location |
add(Direction dir)
Returns the location after moving from the current location following a given direction.
|
Location |
add(int _x,
int _y)
Returns the location after moving from the current location following vector (_x,_y).
|
Direction |
directionTo(Location loc)
Returns the direction that gets the closest to a given location.
|
int |
distanceSquared(Location loc)
Returns the squared euclidean distance between this location and the given one.
|
boolean |
isEqual(Location loc)
Returns if the given location is equal to this (in value).
|
java.lang.String |
toString() |
public int x
public int y
public Location(int x_,
int y_)
x_ - x-coordinate.y_ - y-coordinate.public Location()
public Location add(Direction dir)
dir - Given directionpublic Location add(int _x, int _y)
_x - x-component._y - y-component.public Direction directionTo(Location loc)
loc - Given location.public boolean isEqual(Location loc)
loc - Given locationpublic int distanceSquared(Location loc)
loc - Given location.public java.lang.String toString()
toString in class java.lang.Object