All Packages Class Hierarchy This Package Previous Next Index
Interface com.monpetitcoin.java.PrisonerGame.GameBoard
- public abstract interface GameBoard
This interface is used to defined a common behavior for a game board.
A game board must be able to:
- communicate what kind of graphical representation it expects from the pawns
(as defined by the SHAPE_* constants)
- add a new Pawn to itself
- communicate the maximum number of neighbors to be expected
- transmit its neighbors list to a Pawn
- iterate through the Pawns constituting the board or getting a specific Pawn
- Version:
- 1.00, 21 August 2001
- Author:
- François Suter
- See Also:
- com.monpetitcoin.java.PrisonerGame.Pawn
-
SHAPE_CIRCLE
- This constant is used to indicate that the board expects its Pawns to draw themselves as circles
-
SHAPE_HEXAGON
- This constant is used to indicate that the board expects its Pawns to draw themselves as hexagons
-
SHAPE_SQUARE
- This constant is used to indicate that the board expects its Pawns to draw themselves as squares
-
getItem(int)
-
-
getMaxNeighbors()
-
-
getTileShape()
-
-
hasNext()
- Check if there is a further Pawn in the board.
-
hasPrevious()
- Check if there is a previous Pawn in the board.
-
lastIndex()
- This method positions the iterator on the last position of the board.
-
newItem(Pawn)
-
-
next()
- Return the next Pawn in the board.
-
previous()
- Return the previous Pawn in the board.
-
reset()
- This method positions the iterator on the first position of the board.
-
setNeighborsLists()
- This method computes the list of neighbors for a given Pawn and transmit it to the Pawn
by invoking its setNeighbors() method.
SHAPE_SQUARE
public static final int SHAPE_SQUARE
- This constant is used to indicate that the board expects its Pawns to draw themselves as squares
SHAPE_HEXAGON
public static final int SHAPE_HEXAGON
- This constant is used to indicate that the board expects its Pawns to draw themselves as hexagons
SHAPE_CIRCLE
public static final int SHAPE_CIRCLE
- This constant is used to indicate that the board expects its Pawns to draw themselves as circles
newItem
public abstract boolean newItem(com.monpetitcoin.java.PrisonerGame.Pawn newPawn)
- Returns:
-
true if the Pawn is successfully added
false if the board is full and the Pawn couldn't be added
getTileShape
public abstract int getTileShape()
- Returns:
- the value of the appropriate SHAPE_* constant
getMaxNeighbors
public abstract int getMaxNeighbors()
- Returns:
- the maximum number of neighbors expected given the geometry of the board
(e.g. 8 for a square grid, 6 for an hexagonal grid)
setNeighborsLists
public abstract void setNeighborsLists()
- This method computes the list of neighbors for a given Pawn and transmit it to the Pawn
by invoking its setNeighbors() method.
- See Also:
- setNeighbors
next
public abstract com.monpetitcoin.java.PrisonerGame.Pawn next()
- Return the next Pawn in the board.
This method is part of the board's built-in iterator.
- Returns:
- the next Pawn on the board, or
null if the end of the board has been reached.
hasNext
public abstract boolean hasNext()
- Check if there is a further Pawn in the board.
This method is part of the board's built-in iterator.
- Returns:
-
true if there is at least one more Pawn to be reached with the iterator
false if the iterator has reached the end of the board.
previous
public abstract com.monpetitcoin.java.PrisonerGame.Pawn previous()
- Return the previous Pawn in the board.
This method is part of the board's built-in iterator.
- Returns:
- the previous Pawn on the board, or
null if the beginning of the board has been reached.
hasPrevious
public abstract boolean hasPrevious()
- Check if there is a previous Pawn in the board.
This method is part of the board's built-in iterator.
- Returns:
-
true if there is at least one more Pawn to be reached before the beginning of the board
false if the iterator has reached the beginning of the board.
reset
public abstract void reset()
- This method positions the iterator on the first position of the board.
This method is part of the board's built-in iterator. No other method of the iterator should
reset the board.
lastIndex
public abstract void lastIndex()
- This method positions the iterator on the last position of the board.
This method is part of the board's built-in iterator.
getItem
public abstract com.monpetitcoin.java.PrisonerGame.Pawn getItem(int itemID)
- Parameters:
- itemID - the unique ID number of a Pawn
- Returns:
- the Pawn identified by the ID number
All Packages Class Hierarchy This Package Previous Next Index