Piezas.cpp
Piece Piezas::dropPiece(int column)
{
  //First check if given column is out of bounds
  if(column >= BOARD_COLS)
  {
    //change turns if placed out of bounds
    if(turn == X)
      turn = O;
    else
      turn = X;
    return Invalid; 
  }

  //Switch on turns X and O
  switch(turn)
  {
    //if turn is X
    case X:
      {
        for(int i = 0; i < BOARD_ROWS; i++)
        {
          for(int j = 0; j < BOARD_COLS; j++)
          {
            //check to see we have right column, and is not already taken up by X or O
            if( (j == column) && (board[i][j] != X) && (board[i][j] != O) )
            {
              board[i][j] = X;
              turn = O;
              return X;
            }
          }
        }//for
        break;
      }
    //if turn is O
    case O:
      {
        for(int i = 0; i < BOARD_ROWS; i++)
        {
          for(int j = 0; j < BOARD_COLS; j++)
          {
            if( j == column && (board[i][j] != X) && (board[i][j] != O) )
            {
              board[i][j] = O;
              turn = X;
              return O;
            }
          }
        }//for
        break;
      }
  }//switch
    return Blank;
}
/**
 * Places a piece of the current turn on the board, returns what
 * piece is placed, and toggles which Piece's turn it is. dropPiece does 
 * NOT allow to place a piece in a location where a column is full.
 * In that case, placePiece returns Piece Blank value 
 * Out of bounds coordinates return the Piece Invalid value
 * Trying to drop a piece where it cannot be placed loses the player's turn
**/
Places a piece of the current turn on the board, returns what
piece is placed, and toggles which Piece's turn it is. dropPiece does
NOT allow to place a piece in a location where a column is full.
In that case, placePiece returns Piece Blank value
Out of bounds coordinates return the Piece Invalid value
Trying to drop a piece where it cannot be placed loses the player's turn
Places a piece of the current turn on the board returns what piece is placed and toggles which Piece ' s turn it is . dropPiece does NOT allow to place a piece in a location where a column is full . In that case placePiece returns Piece Blank value Out of bounds coordinates return the Piece Invalid value Trying to drop a piece where it cannot be placed loses the player ' s turn
Piece Piezas::dropPiece(int column)
{
  if(column >= BOARD_COLS)
  {
    if(turn == X)
      turn = O;
    else
      turn = X;
    return Invalid; 
  }
  switch(turn)
  {
    case X:
      {
        for(int i = 0; i < BOARD_ROWS; i++)
        {
          for(int j = 0; j < BOARD_COLS; j++)
          {
            if( (j == column) && (board[i][j] != X) && (board[i][j] != O) )
            {
              board[i][j] = X;
              turn = O;
              return X;
            }
          }
        }
        break;
      }
    case O:
      {
        for(int i = 0; i < BOARD_ROWS; i++)
        {
          for(int j = 0; j < BOARD_COLS; j++)
          {
            if( j == column && (board[i][j] != X) && (board[i][j] != O) )
            {
              board[i][j] = O;
              turn = X;
              return O;
            }
          }
        }
        break;
      }
  }
    return Blank;
}
Piece Piezas :: dropPiece ( int column ) { if ( column >= BOARD_COLS ) { if ( turn == X ) turn = O ; else turn = X ; return Invalid ; } switch ( turn ) { case X : { for ( int i = 0 ; i < BOARD_ROWS ; i ++ ) { for ( int j = 0 ; j < BOARD_COLS ; j ++ ) { if ( ( j == column ) && ( board [ i ] [ j ] != X ) && ( board [ i ] [ j ] != O ) ) { board [ i ] [ j ] = X ; turn = O ; return X ; } } } break ; } case O : { for ( int i = 0 ; i < BOARD_ROWS ; i ++ ) { for ( int j = 0 ; j < BOARD_COLS ; j ++ ) { if ( j == column && ( board [ i ] [ j ] != X ) && ( board [ i ] [ j ] != O ) ) { board [ i ] [ j ] = O ; turn = X ; return O ; } } } break ; } } return Blank ; }
Places a piece of the current turn on the board, returns what
 piece is placed, and toggles which Piece's turn it is.
Places a piece of the current turn on the board returns what piece is placed and toggles which Piece ' s turn it is .
//First check if given column is out of bounds //change turns if placed out of bounds //Switch on turns X and O //if turn is X //check to see we have right column, and is not already taken up by X or O //for //if turn is O //for //switch