org.smtose.shadowedhorizons.world
Class Position

java.lang.Object
  extended byorg.smtose.shadowedhorizons.world.Position

public class Position
extends java.lang.Object

Provides a cartesian style positioning system.

The Position class is copyright© 2005 smtose.org (www.smtose.org)

Author:
Gregory Brown, smtose.org

Constructor Summary
Position()
          Constructs a Position object with coordinates (0,0).
Position(int x, int y)
          Constructs a Position object with coordinates (x,y)
 
Method Summary
 Position copy()
          Returns a new Position with the same coordinates as the original Position
 boolean equals(Position p)
          Checks to see if one Position's coordinates are the same as anothers
 int getX()
          Gets the Position's x coordinate
 int getY()
          Gets the Position's y coordinate
 void set(int x, int y)
          Sets the Position's x and y coordinates
 void set(Position p)
          Sets the Position coordinates to be equal to the coordinates of another Position
 void setX(int x)
          Sets the Position's x coordinate
 void setY(int y)
          Sets the Position's y coordinate
 java.lang.String toString()
          Represents this location as a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Position

public Position()
Constructs a Position object with coordinates (0,0).


Position

public Position(int x,
                int y)
Constructs a Position object with coordinates (x,y)

Parameters:
x - position's x coordinate
y - position's y coordinate
Method Detail

getX

public int getX()
Gets the Position's x coordinate

Returns:
position's x coordinate

getY

public int getY()
Gets the Position's y coordinate

Returns:
position's y coordinate

setX

public void setX(int x)
Sets the Position's x coordinate

Parameters:
x - The value to set the x coordinate to

setY

public void setY(int y)
Sets the Position's y coordinate

Parameters:
y - The value to set the y coordinate to

set

public void set(int x,
                int y)
Sets the Position's x and y coordinates

Parameters:
x - The value to set the x coordinate to
y - The value to set the y coordinate to

set

public void set(Position p)
Sets the Position coordinates to be equal to the coordinates of another Position

Parameters:
p - The Position that contains the coordinates to be set to.

copy

public Position copy()
Returns a new Position with the same coordinates as the original Position

Returns:
The new Position

equals

public boolean equals(Position p)
Checks to see if one Position's coordinates are the same as anothers

Parameters:
p - The Position to test against
Returns:
True if equal, false otherwise.

toString

public java.lang.String toString()
Represents this location as a string.

Returns:
a string indicating the row and column of the location in (row, col) format