turn system java code example
Example 1: how to make it another player's turn java
g.fillOval(3 + 13*col, 3 + 13*row, 10, 10);
Example 2: how to make it another player's turn java
public void paint(Graphics g) {
/* Draw grid lines in darkGray. */
g.setColor(Color.darkGray);
for (int i = 1; i < 13; i++) {
g.drawLine(1 + 13*i, 0, 1 + 13*i, getSize().height);
g.drawLine(0, 1 + 13*i, getSize().width, 1 + 13*i);
}
/* Draw a two-pixel black border around the edges of the board. */
g.setColor(Color.black);
g.drawRect(0,0,getSize().width-1,getSize().height-1);
g.drawRect(1,1,getSize().width-3,getSize().height-3);
/* Draw the pieces that are on the board. */
for (int row = 0; row < 13; row++)
for (int col = 0; col < 13; col++)
if (board[row][col] != EMPTY)
drawPiece(g, board[row][col], row, col);
} // end paint()
Example 3: how to make it another player's turn java
private boolean winner(int row, int col) {
// This is called just after a piece has been played on the
// square in the specified row and column. It determines
// whether that was a winning move by counting the number
// of squares in a line in each of the four possible
// directions from (row,col). If there are 5 squares (or more)
// in a row in any direction, then the game is won.
if (count( board[row][col], row, col, 1, 0 ) >= 5)
return true;
if (count( board[row][col], row, col, 0, 1 ) >= 5)
return true;
if (count( board[row][col], row, col, 1, -1 ) >= 5)
return true;
if (count( board[row][col], row, col, 1, 1 ) >= 5)
return true;
/* When we get to this point, we know that the game is not won. */
return false;
} // end winner()