Class Board

java.lang.Object
  extended by Board

public class Board
extends java.lang.Object

The class Board represents the board with all pieces and holes.


Field Summary
static java.lang.String ERR_INVALID_BOARD_SIZE
          error message: invalid board size
static java.lang.String ERR_INVALID_SITUATION_CHAR
          error message: invalid character in situation string
 int height
          the height of the board
static int MAX_HEIGHT
          minimum width of an Othello-Game board
static int MAX_WIDTH
          minimum width of an Othello-Game board
static int MIN_HEIGHT
          minimum width of an Othello-Game board
static int MIN_WIDTH
          minimum width of an Othello-Game board
 int width
          the width of the board
 
Constructor Summary
Board(int width, int height)
          Constructor for a board object.
Board(int width, int height, java.lang.String situation)
          Constructor for a board object.
 
Method Summary
static boolean checkBoardSize(int width, int height)
          Check if the board size is valid.
 Field get(int x, int y)
          Get the piece at the position (x|y).
 Field get(Position position)
          Get the piece at the position.
 boolean isPositionOnBoard(Position pos)
          Checks if a position is on the board.
static boolean isSituationStringValid(int width, int height, java.lang.String situation)
          Checks if the given situation string is valid.
 java.lang.String niceRepresentation()
          This method returns a nice representation of the board.
 void set(int x, int y, Field player)
          This method sets a piece or a hole on the board.
 void set(Position pos, Field player)
          This method sets a piece or a hole on the board.
 java.lang.String toString()
          Returns the String representation of a board object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ERR_INVALID_SITUATION_CHAR

public static final java.lang.String ERR_INVALID_SITUATION_CHAR
error message: invalid character in situation string

See Also:
Constant Field Values

ERR_INVALID_BOARD_SIZE

public static final java.lang.String ERR_INVALID_BOARD_SIZE
error message: invalid board size

See Also:
Constant Field Values

MIN_WIDTH

public static final int MIN_WIDTH
minimum width of an Othello-Game board

See Also:
Constant Field Values

MAX_WIDTH

public static final int MAX_WIDTH
minimum width of an Othello-Game board

See Also:
Constant Field Values

MIN_HEIGHT

public static final int MIN_HEIGHT
minimum width of an Othello-Game board

See Also:
Constant Field Values

MAX_HEIGHT

public static final int MAX_HEIGHT
minimum width of an Othello-Game board

See Also:
Constant Field Values

width

public final int width
the width of the board


height

public final int height
the height of the board

Constructor Detail

Board

public Board(int width,
             int height)
Constructor for a board object.

Parameters:
width - the width of the board
height - the height of the board

Board

public Board(int width,
             int height,
             java.lang.String situation)
Constructor for a board object.

Parameters:
width - the width of the board
height - the height of the board
situation - the situation of the new board
Method Detail

checkBoardSize

public static boolean checkBoardSize(int width,
                                     int height)
Check if the board size is valid.

Parameters:
width - the width of the board
height - the height of the board
Returns:
true if the board size is valid, otherwise false

isSituationStringValid

public static boolean isSituationStringValid(int width,
                                             int height,
                                             java.lang.String situation)
Checks if the given situation string is valid.

Parameters:
width - the width of the board
height - the height of the board
situation - the situation string
Returns:
true if the string is valid for this board, otherwise false

set

public void set(int x,
                int y,
                Field player)
This method sets a piece or a hole on the board. It does NOT check if this is a valid move.

Parameters:
x - The x-coordinate
y - The y-coordinate
player - The player who wants to set the piece

set

public void set(Position pos,
                Field player)
This method sets a piece or a hole on the board. It does NOT check if this is a valid move.

Parameters:
pos - the position where you want to set the new piece
player - The player who wants to set the piece

get

public Field get(int x,
                 int y)
Get the piece at the position (x|y).

Parameters:
x - the x-coordinate of the piece you want to get
y - the y-coordinate of the piece you want to get
Returns:
the piece or null

get

public Field get(Position position)
Get the piece at the position.

Parameters:
position - the position of the piece you want to get
Returns:
the piece or null

isPositionOnBoard

public boolean isPositionOnBoard(Position pos)
Checks if a position is on the board.

Parameters:
pos - the positon you want to check
Returns:
true if the position is on the board, otherwise false

niceRepresentation

public java.lang.String niceRepresentation()
This method returns a nice representation of the board.

Returns:
the nice String representation of the object.

toString

public java.lang.String toString()
Returns the String representation of a board object.

Overrides:
toString in class java.lang.Object
Returns:
the String representation of a board object