org.moyoman.util
Class NumberedStone

java.lang.Object
  |
  +--org.moyoman.util.Point
        |
        +--org.moyoman.util.Stone
              |
              +--org.moyoman.util.NumberedStone
All Implemented Interfaces:
Cloneable, Serializable

public class NumberedStone
extends Stone
implements Serializable

This class represents a stone and the move number it was made on. Note that while there are only 361 total Point objects and 1083 Stone objects ever created, a new NumberedStone object is created each time one is needed. Therefore, it may be less useful in applications such as lookahead search, where large numbers of objects are used.

See Also:
Serialized Form

Field Summary
private  short number
          The number of the move.
 
Fields inherited from class org.moyoman.util.Stone
 
Fields inherited from class org.moyoman.util.Point
 
Constructor Summary
NumberedStone(int num, Stone s)
          Create a new NumberedStone object.
NumberedStone(short num, Color color, int x, int y)
          Create a new NumberedStone object.
NumberedStone(short num, Stone s)
          Create a new NumberedStone object.
 
Method Summary
 Object clone()
          Return a clone of this object.
 boolean equals(Object o)
          Compare this object with another for equality.
 short getMoveNumber()
          Get the number of the move.
 int hashCode()
          Get a unique integer which represents this object.
 String toString()
          Get a String representation of the object.
 
Methods inherited from class org.moyoman.util.Stone
castToStone, get, get, getAdjacentStonesOfSameColor, getColor
 
Methods inherited from class org.moyoman.util.Point
castToPoint, get, getAdjacentPoints, getConcentricPoints, getX, getY, isInCorner, isOnSide
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

number

private short number
The number of the move.

Constructor Detail

NumberedStone

public NumberedStone(short num,
                     Color color,
                     int x,
                     int y)
              throws IllegalArgumentException
Create a new NumberedStone object.

Parameters:
num - The move number.
color - The color of the move.
x - The horizontal coordinate of the move.
y - The vertical coordinate of the move.
Throws:
IllegalArgumentException - Thrown if the x or y coordinates are out of range.

NumberedStone

public NumberedStone(short num,
                     Stone s)
              throws IllegalArgumentException
Create a new NumberedStone object.

Parameters:
num - The move number.
s - The stone which is the move.
Throws:
IllegalArgumentException - Thrown if the x or y coordinates are out of range.

NumberedStone

public NumberedStone(int num,
                     Stone s)
              throws IllegalArgumentException
Create a new NumberedStone object. This is just for convenience in case an int is passed in instead of a short.

Parameters:
num - The move number.
s - The stone which is the move.
Throws:
IllegalArgumentException - Thrown if the x or y coordinates are out of range.
Method Detail

getMoveNumber

public short getMoveNumber()
Get the number of the move.

Returns:
The move number.

toString

public String toString()
Get a String representation of the object.

Overrides:
toString in class Stone
Returns:
A String object which represents the object.

hashCode

public int hashCode()
Get a unique integer which represents this object. Two NumberedStone objects will have the same hash code value if and only if they have the same move number, color, and x and y coordinates. A NumberedStone object will never have the same hash code value as a Stone or Point object.

Overrides:
hashCode in class Stone
Returns:
An int which is the hashcode for this object.

equals

public boolean equals(Object o)
Compare this object with another for equality. They are considered equal if they are both of type NumberedStone, and have the same hash code value.

Overrides:
equals in class Stone
Parameters:
o - The object to be compared with this one.
Returns:
A boolean value which is true if the two objects are the same, or false.

clone

public Object clone()
Return a clone of this object.

Overrides:
clone in class Stone
Returns:
A NumberedStone object.