org.moyoman.util
Class Rules

java.lang.Object
  |
  +--org.moyoman.util.Rules
All Implemented Interfaces:
Serializable

public class Rules
extends Object
implements Serializable

This class represents the rule set to be used.

See Also:
Serialized Form

Field Summary
static Rules AGA
          A Rules object representing the AGA rule set.
private static short AGA_FLAG
          Use AGA rules.
static Rules CHINESE
          A Rules object representing the Chinese rule set.
private static short CHINESE_FLAG
          Use Chinese rules.
static Rules ING
          A Rules object representing the ING rule set.
private static short ING_FLAG
          Use ING rules.
static Rules JAPANESE
          A Rules object representing the Japanese rule set.
private static short JAPANESE_FLAG
          Use Japanese rules.
private  short rules
          This has the value of one of the constants defining a rule set.
 
Constructor Summary
protected Rules(short type)
          Select the rule set to use.
 
Method Summary
 boolean equals(Object o)
          Determine if two objects are equal.
static Rules getDefault()
          Get the default rules set.
 float getKomi(Handicap h)
           
 int hashCode()
          Return a hashcode for this object.
 String toString()
          Return a String representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

JAPANESE_FLAG

private static final short JAPANESE_FLAG
Use Japanese rules.

See Also:
Constant Field Values

CHINESE_FLAG

private static final short CHINESE_FLAG
Use Chinese rules.

See Also:
Constant Field Values

AGA_FLAG

private static final short AGA_FLAG
Use AGA rules.

See Also:
Constant Field Values

ING_FLAG

private static final short ING_FLAG
Use ING rules.

See Also:
Constant Field Values

JAPANESE

public static final Rules JAPANESE
A Rules object representing the Japanese rule set.


CHINESE

public static final Rules CHINESE
A Rules object representing the Chinese rule set.


AGA

public static final Rules AGA
A Rules object representing the AGA rule set.


ING

public static final Rules ING
A Rules object representing the ING rule set.


rules

private short rules
This has the value of one of the constants defining a rule set.

Constructor Detail

Rules

protected Rules(short type)
         throws IllegalArgumentException
Select the rule set to use.

Parameters:
type - The rules to use.
Throws:
IllegalArgumentException - Thrown if the type parameter is out of range.
Method Detail

getDefault

public static Rules getDefault()
Get the default rules set.

Returns:
A Rules object which is the default.

getKomi

public float getKomi(Handicap h)

toString

public String toString()
Return a String representation of this object. This should be an internationalized String.

Overrides:
toString in class Object
Returns:
A String.

hashCode

public int hashCode()
Return a hashcode for this object. It might seem like this is not necessary because the flyweight pattern is used, but bugs could occur after a game is reloaded due to two objects referring the same rule set existing after deserialization.

Overrides:
hashCode in class Object
Returns:
An int which is the hash code.

equals

public boolean equals(Object o)
Determine if two objects are equal. They are equal if they are both Rules objects, and have the same hashcode.

Overrides:
equals in class Object
Parameters:
o - The object to be compared with this one.
Returns:
true if the objects are the same, or false.