Graphical User Interface for a Board used in the teaching of UW's 100 level CS courses
Constructor Summary | |
---|---|
Board(int cols)
The constructor to build a one-dimensional board: One row and N columns. |
|
Board(int rows,
int cols)
The constructor to build a two-dimensional board. |
Method Summary | |
---|---|
void |
displayMessage(String theMessage)
Sets the message to be displayed under the board. |
void |
drawLine(int row1,
int col1,
int row2,
int col2)
Draws a line on the board using the given co-ordinates as endpoints |
Coordinate |
getClick()
Accepts input from the user. |
int |
getColumns()
Returns the number of columns of the board. |
int |
getPosition()
Like getClick(), but for one-dimensional boards. |
int |
getRows()
Returns the number of rows of the board. |
void |
putPeg(String theColour,
int col)
Places a coloured gamepiece in the designated square on the board (used in one-dimensional boards). |
void |
putPeg(String theColour,
int row,
int col)
Places a coloured gamepiece in the designated square on the board. |
void |
removeLine(int row1,
int col1,
int row2,
int col2)
Removes a line, if one exists, using the given co-ordinates as endpoints |
void |
removePeg(int col)
Removes any gamepiece on the designated square, if one exists. |
void |
removePeg(int row,
int col)
Removes any gamepiece on the designated square, if one exists. |
Constructor Detail |
---|
public Board(int cols)
cols
- The number of columns on the boardpublic Board(int rows, int cols)
rows
- The number of rows on the boardcols
- The number of columns on the boardMethod Detail |
---|
public void displayMessage(String theMessage)
theMessage
- The text message to be displayed below the board.public void putPeg(String theColour, int row, int col)
theColour
- The colour of the gamepiece. Possible values are "yellow", "blue", "cyan", "green",
"pink", "black", "white", "red" and "orange"row
- The row on which to place the the gamepiececol
- The column on which to place the gamepiecepublic void putPeg(String theColour, int col)
theColour
- The colour of the gamepiece. Possible values are "yellow", "blue", "cyan", "green",
"pink", "black", "white", "red" and "orange"col
- The column on which to place the gamepiecepublic void removePeg(int row, int col)
row
- The row of the gamepiece to removecol
- The column of the gamepiece to removepublic void removePeg(int col)
col
- The column of the gamepiece to removepublic void drawLine(int row1, int col1, int row2, int col2)
row1
- The row of the starting square of the linecol1
- The column of the starting square of the linerow2
- The row of the terminating square of the linecol2
- The column of the terminating square of the linepublic void removeLine(int row1, int col1, int row2, int col2)
row1
- The row of the starting square of the linecol1
- The column of the starting square of the linerow2
- The row of the terminating square of the linecol2
- The column of the terminating square of the linepublic Coordinate getClick()
public int getPosition()
public int getColumns()
public int getRows()