vitro.grid
Class Location

java.lang.Object
  extended by vitro.grid.Location

public class Location
extends Object

A Location represents a position on a Grid.


Field Summary
 int x
          The grid column of this Location.
 int y
          The grid row of this Location.
 
Constructor Summary
Location(Grid g, int x, int y)
          Construct a new Location.
 
Method Summary
 Location add(int x, int y)
          Create a new Location relative to this one given X and Y offsets.
 boolean equals(Object o)
           
 int hashCode()
           
 boolean passable(Actor a)
          Check the passability of this Location respecting the passable() predicate of the parent Grid.
 String toString()
           
 boolean valid()
          Confirm this Location is within the bounds of its Grid.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public final int x
The grid column of this Location.


y

public final int y
The grid row of this Location.

Constructor Detail

Location

public Location(Grid g,
                int x,
                int y)
Construct a new Location.

Parameters:
g - the target Grid.
x - the grid column of this Location.
y - the grid row of this Location.
Method Detail

valid

public boolean valid()
Confirm this Location is within the bounds of its Grid.

Returns:
true if this Location is in bounds.

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

add

public Location add(int x,
                    int y)
Create a new Location relative to this one given X and Y offsets.

Parameters:
x - the x-offset of the new Location.
y - the y-offset of the new Location.
Returns:
the relative Location.

passable

public boolean passable(Actor a)
Check the passability of this Location respecting the passable() predicate of the parent Grid.

Parameters:
a - the Actor to check.
Returns:
true if the specified Actor can move to this Location.