/** * A position on the on the sudoku board. * This captures the value at that position as well as the * possible values that the position could have * @author gtowell * Created: Oct 2020 * Modified: Oct 2021 */ public class Spot { int value; // the number in the location. // 0 is empty boolean[] legalMoves; // an array of legal moves. Only meaningful // when value is 0 public Spot() { value=0; legalMoves = new boolean[9]; } // make a spot with this value. public Spot(int ival) { this(); value = ival; } // copy constructor // but only copy the value, not the legal moves public Spot(Spot oldSpot) { this(); value=oldSpot.value; } // what is says. public void clearLegal() { for (int i=0; i<9; i++) legalMoves[i]=true; } public String toString() { if (value>0) return ""+value; StringBuffer sb = new StringBuffer(); sb.append("-["); for (int i=0; i<9; i++) { if (legalMoves[i]) { sb.append(" "); sb.append(i+1); } } sb.append("]"); return sb.toString(); } }