sysModel.env
Class NoGridEnv.Location

java.lang.Object
  extended by sysModel.env.NoGridEnv.Location
Enclosing class:
NoGridEnv

public static class NoGridEnv.Location
extends java.lang.Object

Concrete location class.

Author:
Mathias G. Ricken

Field Summary
private  double _x
          Column.
private  double _y
          Row.
 
Constructor Summary
NoGridEnv.Location(double x, double y)
          Constructor.
 
Method Summary
 NoGridEnv.Location getNeighbor(NoGridEnv.Direction dir)
          Return the location of a neighbor in the given direction.
 double getX()
          Return column.
 double getY()
          Return row.
 boolean inSquare(NoGridEnv.Location other, NoGridEnv.Direction forward, double side)
          Return true of the other location is in a square with this location at the center, facing in the given direction, with sides of the specified length.
static NoGridEnv.Location parse(Lexer l)
          Parses a location.
 boolean same(NoGridEnv.Location other)
          Return true of this location is the same as the other.
 void setX(double _x)
          Set column.
 void setY(double _y)
          Set row.
 java.lang.String toString()
          Overridden toString method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_x

private double _x
Column.


_y

private double _y
Row.

Constructor Detail

NoGridEnv.Location

public NoGridEnv.Location(double x,
                          double y)
Constructor.

Parameters:
x - column
y - row
Method Detail

getX

public double getX()
Return column.

Returns:
double column

getY

public double getY()
Return row.

Returns:
double row

setX

public void setX(double _x)
Set column.

Parameters:
_x - New column

setY

public void setY(double _y)
Set row.

Parameters:
_y - New row

same

public boolean same(NoGridEnv.Location other)
Return true of this location is the same as the other.

Parameters:
other - other location
Returns:
true if the locations are the same

inSquare

public boolean inSquare(NoGridEnv.Location other,
                        NoGridEnv.Direction forward,
                        double side)
Return true of the other location is in a square with this location at the center, facing in the given direction, with sides of the specified length.

Parameters:
other - location to compare to
forward - direction the square is facing (this direction is perpendicular to two of the side walls)
side - side length
Returns:
true if the other point is inside

getNeighbor

public NoGridEnv.Location getNeighbor(NoGridEnv.Direction dir)
Return the location of a neighbor in the given direction.

Parameters:
dir - the direction of the neighbor to be returned
Returns:
neighbor in that direction

toString

public java.lang.String toString()
Overridden toString method.

Overrides:
toString in class java.lang.Object
Returns:
string representation

parse

public static NoGridEnv.Location parse(Lexer l)
Parses a location.

Parameters:
l - parser to read from
Returns:
parsed location