Class Direction

java.lang.Object
  |
  +--Direction

public class Direction
extends java.lang.Object

This class provides encapsulation a neighborhood in the simulation A neighborhood of a point is like a tic-tac-toe board with the point in in the middle. Each Direction object has two fields, x and y, each of which can be set to -1, 0, +1.


Constructor Summary
Direction()
          constructor for an uninitialized Direction object
Direction(int ix, int iy)
          constructor for an initialized Direction object
 
Method Summary
 int getX()
          Observer for x value of a Direction object
 int getY()
          Observer for y value of a Direction object
 Direction incrDirn(int i)
          scales the components of a direction object by its parameter
 boolean isNull()
          checks for (0,0) direction
 boolean isWithCurrent(Location ll, World myWorld)
          checks if a proposed direction is the same as an E-W or W-E current
 void setX(int ix)
          Mutator for x value of a Direction object
 void setY(int iy)
          Mutator for y value of a Direction object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Direction

public Direction(int ix,
                 int iy)
constructor for an initialized Direction object
Parameters:
ix - - for x direction
iy - - for y direction

Direction

public Direction()
constructor for an uninitialized Direction object
Method Detail

getX

public int getX()
Observer for x value of a Direction object
Returns:
int x

getY

public int getY()
Observer for y value of a Direction object
Returns:
int y

setX

public void setX(int ix)
Mutator for x value of a Direction object
Parameters:
ix - is value with which to set x value

setY

public void setY(int iy)
Mutator for y value of a Direction object
Parameters:
iy - is value with which to set y value

isNull

public boolean isNull()
checks for (0,0) direction
Returns:
true if this is (0,0), false otherwise.

isWithCurrent

public boolean isWithCurrent(Location ll,
                             World myWorld)
checks if a proposed direction is the same as an E-W or W-E current
Parameters:
ll - is current location
myWorld - is current simulation object
Returns:
true if this is with the direction of the current, false otherwise

incrDirn

public Direction incrDirn(int i)
scales the components of a direction object by its parameter
Parameters:
i - is scale factor
Returns:
a new Direction