Context for question 4
This question involves reasoning about a number puzzle that is represented as a two- dimensional array of integers. Each element of the array initially contains a value between 1 and 9, inclusive. Solving the puzzle involves clearing pairs of array elements by setting them to 0. Two elements can be cleared if their values sum to 10 or if they have the same value. The puzzle is considered solved if all elements of the array are cleared.
You will write the constructor and one method of the SumOrSameGame class, which contains the methods that manipulate elements of the puzzle.
public class SumOrSameGame
{
private int[][] puzzle;
/**
* Creates a two-dimensional array and fills it with random integers,
* as described in part (a)
* Precondition: ;
*/
public SumOrSameGame(int numRows, int numCols)
{ / to be implemented in part (a) /}
/**
* Identifies and clears an element of puzzle that can be paired with
* the element at the given row and column, as described in part (b)
* Preconditions: row and col are valid row and column indices in puzzle.
* The element at the given row and column is between 1 and 9, inclusive.
*/
public boolean clearPair(int row, int col)
{ / to be implemented in part (b) /}
/ There may be instance variables, constructors, and methods that are not shown. /
}