toPosition method
The function toPosition
sets the row and column values if they are valid and
returns true, otherwise it returns false.
Args: row (int): The row parameter represents the row number of a position in a grid or matrix. column (int): The "column" parameter represents the column index of a position in a grid or matrix.
Returns: a boolean value. It returns true if the position (row, column) is valid and successfully sets the internal variables _row and _column to the given values. It returns false if the position is not valid.
Implementation
bool toPosition(int row, int column) {
if (validatePosition(row, column)) {
_row = row;
_column = column;
return true;
}
return false;
}