org.vizzini.game
Class IntegerPosition

java.lang.Object
  extended by org.vizzini.game.IntegerPosition
All Implemented Interfaces:
Serializable, Cloneable, Comparable, IPosition

public final class IntegerPosition
extends Object
implements IPosition, Comparable

Provides functionality for a position which represents 2D or 3D coordinates as integers in the game framework. Instances of this class are immutable. Instances are pooled, and are obtained through the get() method. The coordinates must be positive.

Since:
v0.1
Version:
v0.3
Author:
Jeffrey M. Thompson
See Also:
Serialized Form

Method Summary
 IPosition add(int x, int y, int z)
          Add the given position to this.
 IPosition add(IPosition position)
          Add the given position to this.
 Object clone()
          Return a clone of this instance.
 int compareTo(Object object)
          Compare this to the given object.
static void configure(Properties properties)
          Configure this class.
 boolean equals(Object object)
          Return true if this equals another.
static IntegerPosition get()
          Return an integer position with coordinates ( 0, 0, 0 ).
static IntegerPosition get(int x, int y)
          Return an integer position with coordinates ( x, y, 0 ).
static IntegerPosition get(int x, int y, int z)
          Return an integer position for the given coordinates.
static int getDimensionX()
          Return the X dimension of the object pool.
static int getDimensionY()
          Return the Y dimension of the object pool.
static int getDimensionZ()
          Return the Z dimension of the object pool.
static int getInstanceCount()
          Return the count of instances created.
static Set getInstances()
          Return the set of instances so far created.
 int getX()
          Return the x coordinate.
 int getY()
          Return the y coordinate.
 int getZ()
          Return the z coordinate.
 int hashCode()
          Returns a hash code value for the object.
static IntegerPosition parsePosition(String string)
          Parse the given string to create an IntegerPosition.
static void setDimensions(int fileCount, int rankCount, int levelCount)
          Set the dimensions of the pool.
 IPosition subtract(int x, int y, int z)
          Subtract the given position from this.
 IPosition subtract(IPosition position)
          Subtract the given position from this.
 String toParsableString()
          Return a parsable string representation of this object.
 String toString()
          Return a string representation of this object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

configure

public static void configure(Properties properties)
                      throws InstantiationException,
                             IllegalAccessException
Configure this class.

Parameters:
properties - Source of configuration information.
Throws:
InstantiationException
IllegalAccessException
Since:
v0.3

get

public static IntegerPosition get()
Return an integer position with coordinates ( 0, 0, 0 ).

Since:
v0.2

get

public static IntegerPosition get(int x,
                                  int y)
Return an integer position with coordinates ( x, y, 0 ).

Parameters:
x - X coordinate.
y - Y coordinate.
Throws:
IllegalArgumentException - if x less than 0 or y less than 0.
Since:
v0.2

get

public static IntegerPosition get(int x,
                                  int y,
                                  int z)
Return an integer position for the given coordinates.

Parameters:
x - X coordinate.
y - Y coordinate.
z - Z coordinate.
Throws:
IllegalArgumentException - if x less than 0, y less than 0 or z less than 0.
Since:
v0.2

getDimensionX

public static int getDimensionX()
Return the X dimension of the object pool.

Since:
v0.3

getDimensionY

public static int getDimensionY()
Return the Y dimension of the object pool.

Since:
v0.3

getDimensionZ

public static int getDimensionZ()
Return the Z dimension of the object pool.

Since:
v0.3

getInstanceCount

public static int getInstanceCount()
Return the count of instances created.

Since:
v0.2

getInstances

public static Set getInstances()
Return the set of instances so far created.

Since:
v0.3

parsePosition

public static IntegerPosition parsePosition(String string)
Parse the given string to create an IntegerPosition.

Parameters:
string - String to parse.
Since:
v0.1

setDimensions

public static void setDimensions(int fileCount,
                                 int rankCount,
                                 int levelCount)
Set the dimensions of the pool.

Parameters:
fileCount - File count.
rankCount - Rank count.
levelCount - Level count.
Since:
v0.3

add

public IPosition add(IPosition position)
Add the given position to this.

Specified by:
add in interface IPosition
Parameters:
position - The position to add. This is assumed to be a IntegerPosition object.
Returns:
A new position object which is this plus the given position.
Since:
v0.1

add

public IPosition add(int x,
                     int y,
                     int z)
Add the given position to this.

Parameters:
x - The x coordinate to add.
y - The y coordinate to add.
z - The z coordinate to add.
Returns:
A new position object which is this plus the given position.
Since:
v0.1

clone

public final Object clone()
Return a clone of this instance.

Specified by:
clone in interface IPosition
Overrides:
clone in class Object
Since:
v0.1

compareTo

public int compareTo(Object object)
Compare this to the given object.

Specified by:
compareTo in interface Comparable
Returns:
-1, 0, 1 if this is less than, equal to, or greater than object.
Since:
v0.3

equals

public boolean equals(Object object)
Return true if this equals another.

Overrides:
equals in class Object
Since:
v0.1

getX

public int getX()
Return the x coordinate.

Since:
v0.1

getY

public int getY()
Return the y coordinate.

Since:
v0.1

getZ

public int getZ()
Return the z coordinate.

Since:
v0.1

hashCode

public int hashCode()
Returns a hash code value for the object.

Overrides:
hashCode in class Object
Since:
v0.1

subtract

public IPosition subtract(IPosition position)
Subtract the given position from this.

Specified by:
subtract in interface IPosition
Parameters:
position - The position to subtract. This is assumed to be a IntegerPosition object.
Returns:
A new position object which is this minus the given position.
Since:
v0.1

subtract

public IPosition subtract(int x,
                          int y,
                          int z)
Subtract the given position from this.

Parameters:
x - The x coordinate to subtract.
y - The y coordinate to subtract.
z - The z coordinate to subtract.
Returns:
A new position object which is this minus the given position.
Throws:
IllegalArgumentException - if the any coordinate of the subtraction is less than zero.
Since:
v0.1

toParsableString

public String toParsableString()
Return a parsable string representation of this object.

Since:
v0.1

toString

public String toString()
Return a string representation of this object.

Overrides:
toString in class Object
Since:
v0.1


Copyright 2007 Vizzini.org. All Rights Reserved. 2007.12.25.03.00.02