Piezas.cpp
/**
 * 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)
{
    Piece piece = Blank;
    if (column < 0 || column >= BOARD_COLS) {
        piece = Invalid;
    } else {
        bool found_location = false;
        int row = BOARD_ROWS - 1;
        for (row = BOARD_ROWS - 1; row >= 0; --row) {
            if (board[row][column] != Blank) {
                found_location = false;
                break;
            } else if (row > 0 && board[row - 1][column] != Blank && board[row][column] == Blank) {
                found_location = true;
                break;
            } else if (row == 0 && board[row][column] == Blank) {
                found_location = true;
                break;
            }
        }
        if (found_location) {
            board[row][column] = turn;
            piece = board[row][column];
        } else {
            piece = Blank;
        }
    }
    turn = (turn == X) ? O : X;
    return piece;
}
Piece Piezas :: dropPiece ( int column ) { Piece piece = Blank ; if ( column < 0 || column >= BOARD_COLS ) { piece = Invalid ; } else { bool found_location = false ; int row = BOARD_ROWS - 1 ; for ( row = BOARD_ROWS - 1 ; row >= 0 ; -- row ) { if ( board [ row ] [ column ] != Blank ) { found_location = false ; break ; } else if ( row > 0 && board [ row - 1 ] [ column ] != Blank && board [ row ] [ column ] == Blank ) { found_location = true ; break ; } else if ( row == 0 && board [ row ] [ column ] == Blank ) { found_location = true ; break ; } } if ( found_location ) { board [ row ] [ column ] = turn ; piece = board [ row ] [ column ] ; } else { piece = Blank ; } } turn = ( turn == X ) ? O : X ; return piece ; }
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 .
// Out of bounds coordinates // Inside bounds coordinates // Because of the flipped orientation, when you drop the pieces, // they rise up to the top. // If current space is occupied // If previous space is occupied && current space is free // If row == 0 && current space is free // set the turn to the other player