|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectbattlecode.common.MapLocation
public final class MapLocation
This class is an immutable representation of two-dimensional coordinates in the battlecode world.
| Field Summary | |
|---|---|
int |
x
The x-coordinate. |
int |
y
The y-coordinate. |
| Constructor Summary | |
|---|---|
MapLocation(int x,
int y)
Creates a new MapLocation representing the location with the given coordinates. |
|
| Method Summary | |
|---|---|
MapLocation |
add(Direction direction)
Returns a new MapLocation object representing a location one square from this one in the given direction. |
MapLocation |
add(Direction direction,
int multiple)
Returns a new MapLocation object representing a location multiple squares from this one in the given direction. |
MapLocation |
add(int dx,
int dy)
Returns a new MapLocation object translated from this location by a fixed amount |
Direction |
directionTo(MapLocation location)
Returns the Direction from this MapLocation to location. |
int |
distanceSquaredTo(MapLocation location)
Computes the square of the distance from this location to the specified location. |
boolean |
equals(Object obj)
Two MapLocations are regarded as equal iff their coordinates are the same. |
int |
hashCode()
|
boolean |
isAdjacentTo(MapLocation location)
Determines whether this location is adjacent to the specified location. |
MapLocation |
subtract(Direction direction)
Returns a new MapLocation object representing a location one square from this one in the opposite of the given direction. |
String |
toString()
|
static MapLocation |
valueOf(String s)
|
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final int x
public final int y
| Constructor Detail |
|---|
public MapLocation(int x,
int y)
x - the x-coordinate of the locationy - the y-coordinate of the location| Method Detail |
|---|
public boolean equals(Object obj)
equals in class Objectpublic int hashCode()
hashCode in class Objectpublic static MapLocation valueOf(String s)
public String toString()
toString in class Objectpublic final int distanceSquaredTo(MapLocation location)
location - the location to compute the distance squared to
public final boolean isAdjacentTo(MapLocation location)
location - the location to test
public final Direction directionTo(MapLocation location)
location.
If the locations are equal this method returns Direction.OMNI. If
location is null then the return value is Direction.NONE.
location - The location to which the Direction will be calculated
location from this MapLocation.public final MapLocation add(Direction direction)
direction - the direction to add to this location
public final MapLocation add(Direction direction,
int multiple)
multiple squares from this one in the given direction.
direction - the direction to add to this locationmultiple - the number of squares to add
public final MapLocation add(int dx,
int dy)
dx - the amount to translate in the x directiondy - the amount to translate in the y directionpublic final MapLocation subtract(Direction direction)
direction - the direction to subtract from this location
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||