de.tabacha.cgo
Class Field

java.lang.Object
  extended byde.tabacha.cgo.Field
All Implemented Interfaces:
java.lang.Cloneable, Constants, java.io.Serializable

public final class Field
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable, Constants

Just one field on the 19*19 board.

The minimum value of the row and the column is 0, the maximum value is ROW_COUNT-1 and COL_COUNT-1. (Both are defined in Constants.) But this class won't complain if the values are out of range; use method isOutside to test this.

This class does not contain any information about the board and the pieces thereon. To get these informations you have to use the methods of the class Board.
$Id: Field.java,v 1.8 2004/12/23 21:42:43 mk Exp $

Version:
$Revision: 1.8 $
See Also:
Serialized Form
Threadsafe?
false, false for performance

Field Summary
 
Fields inherited from interface de.tabacha.cgo.Constants
BALL, COL_COUNT, DCOL, DOWN, DROW, E, EMPTY, FIRST_DIRECTION, KICK_OFF_FIELD, LAST_DIRECTION, N, NE, NW, OPPOSITE, PIECE, ROW_COUNT, S, SE, SW, UP, UPSIDEDOWN, W
 
Constructor Summary
Field(Field otherField)
          Copy constructor.
Field(int col, int row)
          Constructor.
 
Method Summary
 java.lang.Object clone()
           
 int col()
           
 boolean equals(java.lang.Object obj)
           
 Field fieldIn(byte direction)
          Returns the field that lies one step from this field in the specified direction.
 int hashCode()
           
 boolean isInGoal()
          Returns true if this field is in one of the goals.
 boolean isInGoalOf(boolean player)
          Returns true if this field is in the goal of the specified player.
 boolean isOutside()
          Returns true if this field is not on the board.
static boolean isOutside(int col, int row)
          Returns true if the field with the specified row and column is not on the board.
 void moveIn(byte direction)
          Changes the location of this field.
 int row()
           
 void setCol(int newCol)
           
 void setRow(int newRow)
           
 java.lang.String toString()
           
 Field upsideDown()
          Returns the equivalent field on the other half of the board, mirrored along the central row.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Field

public Field(int col,
             int row)
Constructor.

Parameters:
row - The row of the field
col - The column of the field

Field

public Field(Field otherField)
Copy constructor.

Parameters:
otherField - The field to be copied.
Throws:
java.lang.NullPointerException - If otherField is null.
Method Detail

clone

public java.lang.Object clone()

fieldIn

public final Field fieldIn(byte direction)
Returns the field that lies one step from this field in the specified direction. This field isn't changed.

Parameters:
direction - One of the directions defined in Constants.
Returns:
A new field.

moveIn

public final void moveIn(byte direction)
Changes the location of this field. Moves one step in the specified direction.


equals

public boolean equals(java.lang.Object obj)

upsideDown

public final Field upsideDown()
Returns the equivalent field on the other half of the board, mirrored along the central row.


hashCode

public int hashCode()

isOutside

public final boolean isOutside()
Returns true if this field is not on the board.


isOutside

public static boolean isOutside(int col,
                                int row)
Returns true if the field with the specified row and column is not on the board.


isInGoal

public final boolean isInGoal()
Returns true if this field is in one of the goals.


isInGoalOf

public final boolean isInGoalOf(boolean player)
Returns true if this field is in the goal of the specified player.

Parameters:
player - One of the constants UP or DOWN defined in Constants

col

public final int col()

row

public final int row()

setCol

public void setCol(int newCol)

setRow

public void setRow(int newRow)

toString

public java.lang.String toString()