sysModel.env
Class ASquareEnv.Location

java.lang.Object
  extended by sysModel.env.ASquareEnv.Location
Direct Known Subclasses:
WrappingEnv.Location
Enclosing class:
ASquareEnv

public class ASquareEnv.Location
extends java.lang.Object

Concrete location class.

Author:
Mathias G. Ricken

Field Summary
private  double _x
          Column.
private  double _y
          Row.
 
Constructor Summary
ASquareEnv.Location()
          Constructor.
ASquareEnv.Location(double x, double y)
          Constructor.
 
Method Summary
 ASquareEnv.Location getNeighbor(ASquareEnv.Direction dir)
          Return the location of a neighbor in the given direction.
 double getX()
          Return column.
 double getY()
          Return row.
 boolean inField(ASquareEnv.Location other)
          Return true of the other location is in the same field as this location.
 ASquareEnv.Location parse(Lexer l)
          Parses a location.
 boolean same(ASquareEnv.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

ASquareEnv.Location

public ASquareEnv.Location()
Constructor. Location is (0, 0)


ASquareEnv.Location

public ASquareEnv.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(ASquareEnv.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

inField

public boolean inField(ASquareEnv.Location other)
Return true of the other location is in the same field as this location.

Parameters:
other - location to compare to
Returns:
true if the other point is in the same field

getNeighbor

public ASquareEnv.Location getNeighbor(ASquareEnv.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 ASquareEnv.Location parse(Lexer l)
Parses a location.

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