# Sudoku.java - import java.io.*; / allows us to read from a...

• 5
• 100% (5) 5 out of 5 people found this document helpful

This preview shows page 1 - 2 out of 5 pages.

import java.io.*; // allows us to read from a fileimport java.util.*;public class Sudoku { // The current contents of the cells of the puzzle. private int[][] grid;/** Indicates whether the value in a given cell is fixed * (i.e., part of the initial configuration).* valIsFixed[r][c] is true if the value in the cell * at row r, column c is fixed, and false otherwise.*/private boolean[][] valIsFixed;/** This 3-D array allows us to determine if a given subgrid (i.e.,* a given 3x3 region of the puzzle) already contains a given* value. We use 2 indices to identify a given subgrid:** (0,0) (0,1) (0,2)** (1,0) (1,1) (1,2)* * (2,0) (2,1) (2,2)* * For example, subgridHasVal[0][2][5] will be true if the subgrid* in the upper right-hand corner already has a 5 in it, and false* otherwise.*/private boolean[][][] subgridHasVal;/*** ADD YOUR ADDITIONAL FIELDS HERE. ***///stores whether a given col/row has a given valueprivate boolean[][] colHasVal;private boolean[][] rowHasVal;/* * Constructs a new Puzzle object, which initially* has all empty cells.*/public Sudoku() {this.grid = new int[9][9];this.valIsFixed = new boolean[9][9]; /* * Note that the third dimension of the following array is 10,* because we need to be able to use the possible values * (1 through 9) as indices.*/this.subgridHasVal = new boolean[3][3][10]; /*** INITIALIZE YOUR ADDITIONAL FIELDS HERE. ***/this.rowHasVal = new boolean[9][10];this.colHasVal = new boolean[9][10];}/*

Course Hero member to access this document

Course Hero member to access this document

End of preview. Want to read all 5 pages?