public class SquareBoard
extends java.lang.Object
Constructor and Description |
---|
SquareBoard(int width,
int height)
Creates a new square board with the specified size.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the board, i.e.
|
int |
getBoardHeight()
Returns the board height (in squares).
|
int |
getBoardWidth()
Returns the board width (in squares).
|
java.awt.Component |
getComponent()
Returns a graphical component to draw the board.
|
int |
getRemovedLines()
Returns the number of lines removed since the last clear().
|
java.awt.Color |
getSquareColor(int x,
int y)
Returns the color of an individual square on the board.
|
boolean |
hasFullLines()
Checks if the board contains any full lines.
|
boolean |
isLineEmpty(int y)
Checks if a specified line is empty, i.e.
|
boolean |
isLineFull(int y)
Checks if a specified line is full, i.e.
|
boolean |
isSquareEmpty(int x,
int y)
Checks if a specified square is empty, i.e.
|
void |
removeFullLines()
Removes all full lines.
|
void |
setMessage(java.lang.String message)
Sets a message to display on the square board.
|
void |
setSquareColor(int x,
int y,
java.awt.Color color)
Changes the color of an individual square on the board.
|
void |
update()
Updates the graphical component.
|
public SquareBoard(int width, int height)
width
- the width of the board (in squares)height
- the height of the board (in squares)public boolean isSquareEmpty(int x, int y)
x
- the horizontal position (0 <= x < width)y
- the vertical position (0 <= y < height)public boolean isLineEmpty(int y)
y
- the vertical position (0 <= y < height)public boolean isLineFull(int y)
y
- the vertical position (0 <= y < height)public boolean hasFullLines()
public java.awt.Component getComponent()
public int getBoardHeight()
public int getBoardWidth()
public int getRemovedLines()
public java.awt.Color getSquareColor(int x, int y)
x
- the horizontal position (0 <= x < width)y
- the vertical position (0 <= y < height)public void setSquareColor(int x, int y, java.awt.Color color)
x
- the horizontal position (0 <= x < width)y
- the vertical position (0 <= y < height)color
- the new square color, or null for emptypublic void setMessage(java.lang.String message)
message
- a message to display, or null to remove a
previous messagepublic void clear()
public void removeFullLines()
hasFullLines()
public void update()