How to Make Players Alternate java code example

Example 1: how to make it another player's turn java

int ct = 1;  // Number of pieces in a row belonging to the player.
      
      int r, c;    // A row and column to be examined
      
      r = row + dirX;  // Look at square in specified direction.
      c = col + dirY;
      while ( r >= 0 && r < 13 && c >= 0 && c < 13 
                                        && board[r][c] == player ) {
              // Square is on the board, and it 
              // contains one of the players's pieces.
         ct++;
         r += dirX;  // Go on to next square in this direction.
         c += dirY;
      }

      r = row - dirX;  // Now, look in the opposite direction.
      c = col - dirY;
      while ( r >= 0 && r < 13 && c >= 0 && c < 13 
                                       && board[r][c] == player ) {
         ct++;
         r -= dirX;   // Go on to next square in this direction.
         c -= dirY;
      }

Example 2: how to make it another player's turn java

g.fillOval(3 + 13*col, 3 + 13*row, 10, 10);

Tags:

Java Example