Package Jade
Class Grid
java.lang.Object
Jade.Grid
- All Implemented Interfaces:
jade.util.leap.Serializable
,Serializable
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetCell
(int num) Returns the cell symbol at the specified position in the grid, using the grid indexing convention.getCell
(int row, int col) Returns the cell symbol at the specified position in the grid.Returns the free cells.String[][]
getGrid()
Returns the grid.Returns the symbol of the winner in the grid.boolean
isDraw()
Check if the grid contains a draw.boolean
isEmpty()
Checks if the grid is empty.boolean
isFree
(int row, int col) Checks if a move is legal in the grid, using the grid indexing convention.boolean
isFull()
Checks if the grid is full.boolean
isLegal
(int row, int col) Checks if a move is legal in the grid.boolean
isMySymbolThere
(int row, int col, String symbol) Check if the symbol "symbol" is in the grid at the specified position.boolean
isWinner()
Checks if somebody has won in the grid.void
Prints the grid in a nice way.boolean
Sets the cell symbol at the specified position in the grid.boolean
Sets the cell symbol at the specified position in the grid, using the grid indexing convention.void
Sets the grid.toString()
Returns the grid as a string.
-
Constructor Details
-
Grid
public Grid()
-
-
Method Details
-
getCell
Returns the cell symbol at the specified position in the grid.- Parameters:
row
-col
-- Returns:
- String
-
getCell
Returns the cell symbol at the specified position in the grid, using the grid indexing convention.- Parameters:
num
-- Returns:
- String
-
setCell
Sets the cell symbol at the specified position in the grid. First, we check if the cell is free, using the isLegal(row, col) method. If it is, we set the cell symbol.- Parameters:
row
-col
-value
-- Returns:
- boolean
-
setCell
Sets the cell symbol at the specified position in the grid, using the grid indexing convention.- Parameters:
num
-value
-- Returns:
- boolean
-
isFull
public boolean isFull()Checks if the grid is full.- Returns:
- boolean
-
isEmpty
public boolean isEmpty()Checks if the grid is empty.- Returns:
- boolean
-
isDraw
public boolean isDraw()Check if the grid contains a draw.- Returns:
- boolean
-
isWinner
public boolean isWinner()Checks if somebody has won in the grid.- Returns:
- boolean
-
getWinner
Returns the symbol of the winner in the grid.- Returns:
- String
-
isLegal
public boolean isLegal(int row, int col) Checks if a move is legal in the grid.- Parameters:
row
-col
-- Returns:
- boolean
-
isFree
public boolean isFree(int row, int col) Checks if a move is legal in the grid, using the grid indexing convention.- Parameters:
row
-col
-- Returns:
- boolean
-
isMySymbolThere
Check if the symbol "symbol" is in the grid at the specified position.- Parameters:
row
-col
-symbol
-- Returns:
- boolean
-
getGrid
Returns the grid.- Returns:
- String[][]
-
getFreeCells
Returns the free cells.- Returns:
- List
-
setGrid
Sets the grid.- Parameters:
grid
-
-
printGrid
public void printGrid()Prints the grid in a nice way. -
toString
Returns the grid as a string.
-