edu.ou.pacman.util
Class Location2D

java.lang.Object
  extended by edu.ou.pacman.util.Location2D

public class Location2D
extends java.lang.Object

Class used to represent a 2 dimensional location on the game board.

Author:
Derek Rushing

Constructor Summary
Location2D(int x, int y)
           
Location2D(Location2D other)
           
 
Method Summary
 Direction[] directionsToOther(Location2D other)
          Return the directions from one location to another.
 Direction directionToOther(Location2D other)
          Determines the direction needed to go towards another location.
 double distanceFrom(Location2D other)
          Returns the distance from one location to another.
 boolean equals(java.lang.Object obj)
           
 java.lang.String toString()
           
 int xCoordinate()
           
 int yCoordinate()
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Location2D

public Location2D(int x,
                  int y)

Location2D

public Location2D(Location2D other)
Method Detail

directionToOther

public Direction directionToOther(Location2D other)
Determines the direction needed to go towards another location. If a location is farther in 1 direction then any other, then return it. If the location is the same distance in 2 directions then returns the x_direction.

Parameters:
other - - The location to find the direction towards
Returns:
Return the direction needed to get from this location to another.

directionsToOther

public Direction[] directionsToOther(Location2D other)
Return the directions from one location to another. The farthest direction gets highest precedence, and if both directions are the same distance apart, then the x direction gets highest precedence. If same x or y coordinate then null is returned for the direction.

Parameters:
other - - The other location to go to
Returns:
A direction array of size 2 for the directions needed to get from 1 location to another.

distanceFrom

public double distanceFrom(Location2D other)
Returns the distance from one location to another. Returns it as euclidean distance. Always returns a positive value or 0.

Parameters:
other - - The location to get the distance from
Returns:
The distance from one location to another.

xCoordinate

public int xCoordinate()

yCoordinate

public int yCoordinate()

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object