Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A short discussion on solving a Sudoku puzzle is provided in http://www.sudokuso

ID: 3664171 • Letter: A

Question

A short discussion on solving a Sudoku puzzle is provided in http://www.sudokusolver.com/play/techniques/

You must write a Java SudokuSolver using a recursive, depth-first, brute force technique. You must allow a user to enter a board. You must display a solution in a 9x9 grid format. To receive full credit on this assignment, you must implement some computation-time-saving techniques. They are:

1.) Do not expand a board that has an obvious duplicate row, column and/or 3x3 grid,

2.) End the process when any solution has been discovered.

Explanation / Answer

package diuf.sudoku;

import java.util.*;

/**
* A cell of a sudoku grid.
* <p>
* Holds:
* <ul>
* <li>The grid this cell belongs to
* <li>The x and y coordinates within the grid
* <li>The current value, or <code>0</code> if the cell is empty
* <li>The bitset of potential values for this cell (the candidates).
* </ul>
*/
public class Cell {

private final Grid grid;
private final int x;
private final int y;
private int value = 0;
private BitSet potentialValues = new BitSet(9);


/**
* Create a new cell
* @param grid the grid this cell is part of
* @param x the x coordinate of this cell (0=leftmost, 8=rightmost)
* @param y the y coordinate of this cell (0=topmost, 8=bottommost)
*/
public Cell(Grid grid, int x, int y) {
this.grid = grid;
this.x = x;
this.y = y;
}

/**
* Get the x coordinate of this cell.
* 0 = leftmost, 8 = rightmost
* @return the x coordinate of this cell
*/
public int getX() {
return this.x;
}

/**
* Get the y coordinate of this cell.
* 0 = topmost, 8 = bottommost
* @return the y coordinate of this cell
*/
public int getY() {
return this.y;
}

/**
* Get the value of this cell. Returns <tt>0</tt>
* if this cell is still empty.
* @return the value of this cell.
*/
public int getValue() {
return value;
}

/**
* Get whether this cell is empty
* @return whether this cell is empty
*/
public boolean isEmpty() {
return (value == 0);
}

/**
* Set the value of this cell.
* @param value the value of this cell. Use <tt>0</tt> to
* clear it.
*/
public void setValue(int value) {
this.value = value;
}

/**
* Set the value of this cell, and remove that value
* from the potential values of all controlled cells.
* <p>
* This cell must be empty before this call, and the
* given value must be non-zero.
* @param value the value to set this cell to.
* @see #getHouseCells()
*/
public void setValueAndCancel(int value) {
assert value != 0;
this.value = value;
this.potentialValues.clear();
for (Class<? extends Grid.Region> regionType : grid.getRegionTypes()) {
Grid.Region region = grid.getRegionAt(regionType, this.x, this.y);
for (int i = 0; i < 9; i++) {
Cell other = region.getCell(i);
other.removePotentialValue(value);
}
}
}

/**
* Get the potential values for this cell.
* <p>
* The result is returned as a bitset. Each of the
* bit number 1 to 9 is set if the corresponding
* value is a potential value for this cell. Bit number
* <tt>0</tt> is not used and ignored.
* @return the potential values for this cell
*/
public BitSet getPotentialValues() {
return this.potentialValues;
}

/**
* Test whether the given value is a potential
* value for this cell.
* @param value the potential value to test, between 1 and 9, inclusive
* @return whether the given value is a potential value for this cell
*/
public boolean hasPotentialValue(int value) {
return this.potentialValues.get(value);
}

/**
* Add the given value as a potential value for this cell
* @param value the value to add, between 1 and 9, inclusive
*/
public void addPotentialValue(int value) {
this.potentialValues.set(value, true);
}

/**
* Remove the given value from the potential values of this cell.
* @param value the value to remove, between 1 and 9, inclusive
*/
public void removePotentialValue(int value) {
this.potentialValues.set(value, false);
}

public void removePotentialValues(BitSet valuesToRemove) {
this.potentialValues.andNot(valuesToRemove);
}

public void clearPotentialValues() {
this.potentialValues.clear();
}

/**
* Get the cells that form the "house" of this cell. The
* "house" cells are all the cells that are in the
* same block, row or column.
* <p>
* The iteration order is guaranted to be the same on each
* invocation of this method for the same cell. (this is
* necessary to ensure that hints of the same difficulty
* are always returned in the same order).
* @return the cells that are controlled by this cell
*/
public Collection<Cell> getHouseCells() {
// Use a set to prevent duplicates (cells in both block and row/column)
Collection<Cell> result = new LinkedHashSet<Cell>();
// Iterate on region types (Block, Row, Column)
for (Class<? extends Grid.Region> regionType : grid.getRegionTypes()) {
// Get region on which this cell is
Grid.Region region = grid.getRegionAt(regionType, x, y);
// Add all cell of that region
for (int i = 0; i < 9; i++)
result.add(region.getCell(i));
}
// Remove this cell
result.remove(this);
return result;
}

/**
* Get a string representation of a cell. The notation that
* is used is defined by the {@link Settings} class.
* @param x the horizontal coordinate of the cell (0=leftmost, 8=rightmost)
* @param y the vertical coordinate of the cell (0=topmost, 8=bottommost)
* @return a string representation of the cell
*/
private static String toString(int x, int y) {
Settings settings = Settings.getInstance();
if (settings.isRCNotation())
return "R" + (y + 1) + "C" + (x + 1);
else
return "" + (char)('A' + x) + (y + 1);
}

/**
* Get a complete string representation of this cell.
* <p>
* Returns "Cell " followed by the result of the {@link #toString()} method.
* @return a complete string representation of this cell.
*/
public String toFullString() {
return "Cell " + toString(x, y);
}

/**
* Get a string representation of this cell.
* <p>
* Returned strings are in the form "A1", "A2", "A3", ...
* "I9".
* @return a string representation of this cell.
*/
@Override
public String toString() {
return toString(x, y);
}

/**
* Get a full string representation of multiple cells.
* <p>
* The returned string might be, for example:
* "Cells A1, B4, C3"
* @param cells the cells
* @return a full string representation of the cells
*/
public static String toFullString(Cell... cells) {
StringBuilder builder = new StringBuilder();
builder.append("Cell");
if (cells.length <= 1)
builder.append(" ");
else
builder.append("s ");
for (int i = 0; i < cells.length; i++) {
if (i > 0)
builder.append(",");
Cell cell = cells[i];
builder.append(toString(cell.x, cell.y));
}
return builder.toString();
}

/**
* Get a string representation of multiple cells.
* The returned string is a concatenation of the
* result of calling {@link #toString()} on each cell,
* separated by ",".
* @param cells the cells to convert to a string
* @return a string representation of the given cells.
*/
public static String toString(Cell... cells) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < cells.length; i++) {
if (i > 0)
builder.append(",");
Cell cell = cells[i];
builder.append(toString(cell.x, cell.y));
}
return builder.toString();
}

/**
* Copy this cell to another one. The value and potential values
* are copied, but the grid reference and the coordinates are not.
* @param other the cell to copy this cell to
*/
public void copyTo(Cell other) {
assert this.x == other.x && this.y == other.y;
other.value = this.value;
other.potentialValues = (BitSet)this.potentialValues.clone();
}

}

for cell creation

package diuf.sudoku;

import java.util.*;

/**
* A Sudoku grid.
* <p>
* Contains the 9x9 array of cells, as well as methods
* to manipulate regions (rows, columns and blocks).
* <p>
* Horizontal coordinates (for Cells) range from 0 (leftmost) to
* 8 (rightmost). Vertical coordinates range from 0 (topmost) to
* 8 (bottommost).
*/
public class Grid {

/*
* Cells of the grid. First array index is the vertical index (from top
* to bottom), and second index is horizontal index (from left to right).
*/
private Cell[][] cells = new Cell[9][9];

// Views
private Row[] rows = new Row[9];
private Column[] columns = new Column[9];
private Block[] blocks = new Block[9];


/**
* Create a new 9x9 Sudoku grid. All cells are set to empty
*/
public Grid() {
for (int y = 0; y < 9; y++) {
for (int x = 0; x < 9; x++) {
cells[y][x] = new Cell(this, x, y);
}
}
// Build subparts views
for (int i = 0; i < 9; i++) {
rows[i] = new Row(i);
columns[i] = new Column(i);
blocks[i] = new Block(i / 3, i % 3);
}
}

/**
* Get the cell at the given coordinates
* @param x the x coordinate (0=leftmost, 8=rightmost)
* @param y the y coordinate (0=topmost, 8=bottommost)
* @return the cell at the given coordinates
*/
public Cell getCell(int x, int y) {
return this.cells[y][x];
}

/**
* Get the 9 regions of the given type
* @param regionType the type of the regions to return. Must be one of
* {@link Grid.Block}, {@link Grid.Row} or {@link Grid.Column}.
* @return the 9 regions of the given type
*/
public Region[] getRegions(Class<? extends Region> regionType) {
if (regionType == Row.class)
return this.rows;
else if (regionType == Column.class)
return this.columns;
else
return this.blocks;
}

/**
* Get the row at the given index.
* Rows are numbered from top to bottom.
* @param num the index of the row to get, between 0 and 8, inclusive
* @return the row at the given index
*/
public Row getRow(int num) {
return this.rows[num];
}

/**
* Get the column at the given index.
* Columns are numbered from left to right.
* @param num the index of the column to get, between 0 and 8, inclusive
* @return the column at the given index
*/
public Column getColumn(int num) {
return this.columns[num];
}

/**
* Get the block at the given index.
* Blocks are numbered from left to right, top to bottom.
* @param num the index of the block to get, between 0 and 8, inclusive
* @return the block at the given index
*/
public Block getBlock(int num) {
return this.blocks[num];
}

/**
* Get the block at the given location
* @param vPos the vertical position, between 0 to 2, inclusive
* @param hPos the horizontal position, between 0 to 2, inclusive
* @return the block at the given location
*/
public Block getBlock(int vPos, int hPos) {
return this.blocks[vPos * 3 + hPos];
}

// Cell values

/**
* Set the value of a cell
* @param x the horizontal coordinate of the cell
* @param y the vertical coordinate of the cell
* @param value the value to set the cell to. Use 0 to clear the cell.
*/
public void setCellValue(int x, int y, int value) {
this.cells[y][x].setValue(value);
}

/**
* Get the value of a cell
* @param x the horizontal coordinate of the cell
* @param y the vertical coordinate of the cell
* @return the value of the cell, or 0 if the cell is empty
*/
public int getCellValue(int x, int y) {
return this.cells[y][x].getValue();
}

/**
* Get the row at the given location
* @param x the horizontal coordinate
* @param y the vertical coordinate
* @return the row at the given coordinates
*/
public Row getRowAt(int x, int y) {
return this.rows[y];
}

/**
* Get the column at the given location
* @param x the horizontal coordinate
* @param y the vertical coordinate
* @return the column at the given location
*/
public Column getColumnAt(int x, int y) {
return this.columns[x];
}

/**
* Get the 3x3 block at the given location
* @param x the horizontal coordinate
* @param y the vertical coordinate
* @return the block at the given coordinates (the coordinates
* are coordinates of a cell)
*/
public Block getBlockAt(int x, int y) {
return this.blocks[(y / 3) * 3 + (x / 3)];
}

public Grid.Region getRegionAt(Class<? extends Grid.Region> regionType, int x, int y) {
if (regionType.equals(Grid.Row.class))
return getRowAt(x, y);
else if (regionType.equals(Grid.Column.class))
return getColumnAt(x, y);
else
return getBlockAt(x, y);
}

public Grid.Region getRegionAt(Class<? extends Grid.Region> regionType, Cell cell) {
return getRegionAt(regionType, cell.getX(), cell.getY());
}

private List<Class<? extends Grid.Region>> _regionTypes = null;

/**
* Get a list containing the three classes corresponding to the
* three region types (row, column and block)
* @return a list of the three region types. The resulting list
* can not be modified
*/
public List<Class<? extends Grid.Region>> getRegionTypes() {
if (_regionTypes == null) {
_regionTypes = new ArrayList<Class<? extends Grid.Region>>(3);
_regionTypes.add(Grid.Block.class);
_regionTypes.add(Grid.Row.class);
_regionTypes.add(Grid.Column.class);
_regionTypes = Collections.unmodifiableList(_regionTypes);
}
return _regionTypes;
}

// Grid regions implementation (rows, columns, 3x3 squares)

/**
* Abstract class representing a region of a sudoku grid. A region
* is either a row, a column or a 3x3 block.
*/
public abstract class Region {

/**
* Get a cell of this region by index. The order in which cells are
* returned according to the index is not defined, but is guaranted
* to be consistant accross multiple invocations of this method.
* @param index the index of the cell to get, between 0 (inclusive)
* and 9 (exclusive).
* @return the cell at the given index
*/
public abstract Cell getCell(int index);

/**
* Get the index of the given cell within this region.
* <p>
* The returned value is consistent with {@link #getCell(int)}.
* @param cell the cell whose index to get
* @return the index of the cell, or -1 if the cell does not belong to
* this region.
*/
public int indexOf(Cell cell) {
/*
* This code is not really used. The method is always overriden
*/
for (int i = 0; i < 9; i++) {
if (getCell(i).equals(cell))
return i;
}
return -1;
}

/**
* Test whether this region contains the given value, that is,
* is a cell of this region is filled with the given value.
* @param value the value to check for
* @return whether this region contains the given value
*/
public boolean contains(int value) {
for (int i = 0; i < 9; i++) {
if (getCell(i).getValue() == value)
return true;
}
return false;
}

/**
* Get the potential positions of the given value within this region.
* The bits of the returned bitset correspond to indexes of cells, as
* in {@link #getCell(int)}. Only the indexes of cells that have the given
* value as a potential value are included in the bitset (see
* {@link Cell#getPotentialValues()}).
* @param value the value whose potential positions to get
* @return the potential positions of the given value within this region
* @see Cell#getPotentialValues()
*/
public BitSet getPotentialPositions(int value) {
BitSet result = new BitSet(9);
for (int index = 0; index < 9; index++) {
result.set(index, getCell(index).hasPotentialValue(value));
}
return result;
}

public BitSet copyPotentialPositions(int value) {
return getPotentialPositions(value); // No need to clone, this is alreay hand-made
}

/**
* Get the cells of this region. The iteration order of the result
* matches the order of the cells returned by {@link #getCell(int)}.
* @return the cells of this region.
*/
public Set<Cell> getCellSet() {
Set<Cell> result = new LinkedHashSet<Cell>();
for (int i = 0; i < 9; i++)
result.add(getCell(i));
return result;
}

/**
* Return the cells that are common to this region and the
* given region
* @param other the other region
* @return the cells belonging to this region and to the other region
*/
public Set<Cell> commonCells(Region other) {
Set<Cell> result = this.getCellSet();
result.retainAll(other.getCellSet());
return result;
}

/**
* Test whether thsi region crosses an other region.
* <p>
* A region crosses another region if they have at least one
* common cell. In particular, any rows cross any columns.
* @param other the other region
* @return whether this region crosses the other region.
*/
public boolean crosses(Region other) {
return !commonCells(other).isEmpty();
}

/**
* Get the number of cells of this region that are still empty.
* @return the number of cells of this region that are still empty
*/
public int getEmptyCellCount() {
int result = 0;
for (int i = 0; i < 9; i++)
if (getCell(i).isEmpty())
result++;
return result;
}

/**
* Get a string representation of this region's type
*/
@Override
public abstract String toString();

/**
* Get a string representation of this region
* @return a string representation of this region
*/
public abstract String toFullString();

}

/**
* A row of a sudoku grid.
*/
public class Row extends Region {

private int rowNum;

public Row(int rowNum) {
this.rowNum = rowNum;
}

public int getRowNum() {
return this.rowNum;
}

@Override
public Cell getCell(int index) {
return cells[rowNum][index];
}

@Override
public int indexOf(Cell cell) {
return cell.getX();
}

@Override
public boolean crosses(Region other) {
if (other instanceof Block) {
Block square = (Block)other;
return rowNum / 3 == square.vNum;
} else if (other instanceof Column) {
return true;
} else if (other instanceof Row) {
Row row = (Row)other;
return this.rowNum == row.rowNum;
} else {
return super.crosses(other);
}
}

@Override
public String toString() {
return "row";
}

@Override
public String toFullString() {
Settings settings = Settings.getInstance();
if (settings.isRCNotation())
return toString() + " R" + (rowNum + 1);
else
return toString() + " " + (rowNum + 1);
}

}

/**
* A column a sudoku grid
*/
public class Column extends Region {

private int columnNum;

public Column(int columnNum) {
this.columnNum = columnNum;
}

public int getColumnNum() {
return this.columnNum;
}

@Override
public Cell getCell(int index) {
return cells[index][columnNum];
}

@Override
public int indexOf(Cell cell) {
return cell.getY();
}

@Override
public boolean crosses(Region other) {
if (other instanceof Block) {
Block square = (Block)other;
return columnNum / 3 == square.hNum;
} else if (other instanceof Row) {
return true;
} else if (other instanceof Column) {
Column column = (Column)other;
return this.columnNum == column.columnNum;
} else {
return super.crosses(other);
}
}

@Override
public String toString() {
return "column";
}

@Override
public String toFullString() {
Settings settings = Settings.getInstance();
if (settings.isRCNotation())
return toString() + " C" + (columnNum + 1);
else
return toString() + " " + (char)('A' + columnNum);
}

}

/**
* A 3x3 block of a sudoku grid.
*/
public class Block extends Region {

private int vNum, hNum;

public Block(int vNum, int hNum) {
this.vNum = vNum;
this.hNum = hNum;
}

public int getVIndex() {
return this.vNum;
}

public int getHIndex() {
return this.hNum;
}

@Override
public Cell getCell(int index) {
return cells[vNum * 3 + index / 3][hNum * 3 + index % 3];
}

@Override
public int indexOf(Cell cell) {
return (cell.getY() % 3) * 3 + (cell.getX() % 3);
}

@Override
public boolean crosses(Region other) {
if (other instanceof Row) {
return ((Row)other).crosses(this);
} else if (other instanceof Column) {
return ((Column)other).crosses(this);
} else if (other instanceof Block) {
Block square = (Block)other;
return this.vNum == square.vNum && this.hNum == square.hNum;
} else {
return super.crosses(other);
}
}

@Override
public String toString() {
return "block";
}

@Override
public String toFullString() {
return toString() + " " + (vNum * 3 + hNum + 1);
}

}

/**
* Get the first cell that cancels the given cell.
* <p>
* More precisely, get the first cell that:
* <ul>
* <li>is in the same row, column or block of the given cell
* <li>contains the given value
* </ul>
* The order used for the "first" is not defined, but is guaranted to be
* consistent accross multiple invocations.
* @param target the cell
* @param value the value
* @return the first cell that share a region with the given cell, and has
* the given value
*/
public Cell getFirstCancellerOf(Cell target, int value) {
for (Class<? extends Region> regionType : getRegionTypes()) {
Region region = getRegionAt(regionType, target.getX(), target.getY());
for (int i = 0; i < 9; i++) {
Cell cell = region.getCell(i);
if (!cell.equals(target) && cell.getValue() == value)
return cell;
}
}
return null;
}

/**
* Copy the content of this grid to another grid.
* The values of the cells and their potential values
* are copied.
* @param other the grid to copy this grid to
*/
public void copyTo(Grid other) {
for (int y = 0; y < 9; y++) {
for (int x = 0; x < 9; x++) {
this.cells[y][x].copyTo(other.cells[y][x]);
}
}
}

/**
* Get the number of occurances of a given value in this grid
* @param value the value
* @return the number of occurances of a given value in this grid
*/
public int getCountOccurancesOfValue(int value) {
int result = 0;
for (int y = 0; y < 9; y++) {
for (int x = 0; x < 9; x++) {
if (cells[y][x].getValue() == value)
result++;
}
}
return result;
}

/**
* Get a string representation of this grid. For debugging
* purpose only.
*/
@Override
public String toString() {
StringBuilder result = new StringBuilder();
for (int y = 0; y < 9; y++) {
for (int x = 0; x < 9; x++) {
int value = getCellValue(x, y);
if (value == 0)
result.append('.');
else
result.append(value);
}
result.append(' ');
}
return result.toString();
}

/**
* Compare two grids for equality. Comparison is based on the values
* of the cells and on the potential values of the empty cells.
*/
@Override
public boolean equals(Object o) {
if (!(o instanceof Grid))
return false;
Grid other = (Grid)o;
for (int y = 0; y < 9; y++) {
for (int x = 0; x < 9; x++) {
Cell thisCell = this.getCell(x, y);
Cell otherCell = other.getCell(x, y);
if (thisCell.getValue() != otherCell.getValue())
return false;
if (!thisCell.getPotentialValues().equals(otherCell.getPotentialValues()))
return false;
}
}
return true;
}

@Override
public int hashCode() {
int result = 0;
for (int y = 0; y < 9; y++) {
for (int x = 0; x < 9; x++) {
Cell cell = getCell(x, y);
result ^= cell.getValue();
result ^= cell.getPotentialValues().hashCode();
}
}
return result;
}

}

for grid creation

package diuf.sudoku;

public enum SolvingTechnique {

HiddenSingle("Hidden Single"),
DirectPointing("Direct Pointing"),
DirectHiddenPair("Direct Hidden Pair"),
NakedSingle("Naked Single"),
DirectHiddenTriplet("Direct Hidden Triplet"),
PointingClaiming("Pointing & Claiming"),
NakedPair("Naked Pair"),
XWing("X-Wing"),
HiddenPair("Hidden Pair"),
NakedTriplet("Naked Triplet"),
Swordfish("Swordfish"),
HiddenTriplet("Hidden Triplet"),
XYWing("XY-Wing"),
XYZWing("XYZ-Wing"),
UniqueLoop("Unique Rectangle / Loop"),
NakedQuad("Naked Quad"),
Jellyfish("Jellyfish"),
HiddenQuad("Hidden Quad"),
BivalueUniversalGrave("Bivalue Universal Grave"),
AlignedPairExclusion("Aligned Pair Exclusion"),
ForcingChainCycle("Forcing Chains & Cycles"),
AlignedTripletExclusion("Aligned Triplet Exclusion"),
NishioForcingChain("Nishio Forcing Chains"),
MultipleForcingChain("Multiple Forcing Chains"),
DynamicForcingChain("Dynamic Forcing Chains"),
DynamicForcingChainPlus("Dynamic Forcing Chains (+)"),
NestedForcingChain("Nested Forcing Chains");

private final String name;

private SolvingTechnique(String name) {
this.name = name;
}

@Override
public String toString() {
return name;
}

}

for solving technique

package diuf.sudoku;

import java.util.*;
import java.util.prefs.*;

/**
* Global settings of the application.
* Implemented using the singleton pattern.
*/
public class Settings {

public final static int VERSION = 1;
public final static int REVISION = 2;
public final static String SUBREV = ".1";

private static Settings instance = null;

private boolean isRCNotation = false;
private boolean isAntialiasing = true;
private boolean isShowingCandidates = true;
private String lookAndFeelClassName = null;

private EnumSet<SolvingTechnique> techniques;


private Settings() {
init();
load();
}

public static Settings getInstance() {
if (instance == null)
instance = new Settings();
return instance;
}

public void setRCNotation(boolean isRCNotation) {
this.isRCNotation = isRCNotation;
save();
}

public boolean isRCNotation() {
return isRCNotation;
}

public void setAntialiasing(boolean isAntialiasing) {
this.isAntialiasing = isAntialiasing;
save();
}

public boolean isAntialiasing() {
return this.isAntialiasing;
}

public void setShowingCandidates(boolean value) {
this.isShowingCandidates = value;
save();
}

public boolean isShowingCandidates() {
return this.isShowingCandidates;
}

public String getLookAndFeelClassName() {
return lookAndFeelClassName;
}

public void setLookAndFeelClassName(String lookAndFeelClassName) {
this.lookAndFeelClassName = lookAndFeelClassName;
save();
}

public EnumSet<SolvingTechnique> getTechniques() {
return EnumSet.copyOf(this.techniques);
}

public void setTechniques(EnumSet<SolvingTechnique> techniques) {
this.techniques = techniques;
}

public boolean isUsingAllTechniques() {
EnumSet<SolvingTechnique> all = EnumSet.allOf(SolvingTechnique.class);
return this.techniques.equals(all);
}

public boolean isUsingOneOf(SolvingTechnique... solvingTechniques) {
for (SolvingTechnique st : solvingTechniques) {
if (this.techniques.contains(st))
return true;
}
return false;
}

public boolean isusingAll(SolvingTechnique... solvingTechniques) {
for (SolvingTechnique st : solvingTechniques) {
if (!this.techniques.contains(st))
return false;
}
return true;
}

public boolean isUsingAllButMaybeNot(SolvingTechnique... solvingTechniques) {
List<SolvingTechnique> list = Arrays.asList(solvingTechniques);
for (SolvingTechnique st : EnumSet.allOf(SolvingTechnique.class)) {
if (!this.techniques.contains(st) && !list.contains(st))
return false;
}
return true;
}

// Load / Save

private void init() {
techniques = EnumSet.allOf(SolvingTechnique.class);
}

public void load() {
try {
Preferences prefs = Preferences.userNodeForPackage(Settings.class);
if (prefs == null)
return; // What can I do there ?
isRCNotation = prefs.getBoolean("isRCNotation", isRCNotation);
isAntialiasing = prefs.getBoolean("isAntialiasing", isAntialiasing);
isShowingCandidates = prefs.getBoolean("isShowingCandidates", isShowingCandidates);
lookAndFeelClassName = prefs.get("lookAndFeelClassName", lookAndFeelClassName);
} catch (SecurityException ex) {
// Maybe we are running from an applet. Do nothing
}
}

public void save() {
try {
Preferences prefs = Preferences.userNodeForPackage(Settings.class);
if (prefs == null)
return;
prefs.putBoolean("isRCNotation", isRCNotation);
prefs.putBoolean("isAntialiasing", isAntialiasing);
prefs.putBoolean("isShowingCandidates", isShowingCandidates);
if (lookAndFeelClassName != null)
prefs.put("lookAndFeelClassName", lookAndFeelClassName);
try {
prefs.flush();
} catch (BackingStoreException ex) {
ex.printStackTrace();
}
} catch (SecurityException ex) {
// Maybe we are running from an applet. Do nothing
}
}

}

for setting

from the program you can create 9 x 9 columns and grid

for addition stuff you surf web .

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote