public class BreakthroughState
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
BLACK
A constant integer value representing "black piece" (in
getPiece(int, int)) and "black player winner" (in getWinner()). |
static int |
NONE
A constant integer value representing "no piece" (in
getPiece(int, int)) and "no winner" (in getWinner()). |
static int |
SIZE
The size of the 8-by-8 square grid.
|
static int |
WHITE
A constant integer value representing "white piece" (in
getPiece(int, int)) and "white player winner" (in getWinner()). |
| Constructor and Description |
|---|
BreakthroughState()
Initialize board with WHITE pawns filling rows 0 and 1 and BLACK pawns filling rows 6 and 7.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getCurrentPlayer()
Return the current player (BLACK/WHITE).
|
int |
getPiece(int row,
int col)
Return the piece (NONE/BLACK/WHITE) at the given 0-based row and column.
|
int |
getWinner()
Return the winner (BLACK/WHITE) of the game or NONE if there is no winner.
|
boolean |
makeMove(int fromRow,
int fromCol,
int toRow,
int toCol)
Make a given 0-based move if and only if it is legal and return whether or not the move was legal.
|
public static final int NONE
getPiece(int, int)) and "no winner" (in getWinner()).public static final int BLACK
getPiece(int, int)) and "black player winner" (in getWinner()).public static final int WHITE
getPiece(int, int)) and "white player winner" (in getWinner()).public static final int SIZE
public BreakthroughState()
public int getPiece(int row,
int col)
row - given rowcol - given columnpublic int getCurrentPlayer()
public int getWinner()
public boolean makeMove(int fromRow,
int fromCol,
int toRow,
int toCol)
fromRow - row piece is moved fromfromCol - column piece is moved fromtoRow - row piece is moved totoCol - column piece is moved to