Package ball.game.sudoku
Class Puzzle
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- ball.util.MapView<Coordinate,V>
-
- ball.util.CoordinateMap<Cell>
-
- ball.game.sudoku.Puzzle
-
- All Implemented Interfaces:
Serializable,Map<Coordinate,Cell>,SortedMap<Coordinate,Cell>,TableModel
public class Puzzle extends CoordinateMap<Cell>
SudokuPuzzle.- Author:
- Allen D. Ball
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ball.util.MapView
MapView.EntrySet
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Constructor Description Puzzle()Sole constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanapply(Rule rule)booleanisLegal()Method to test if the currentCellvalues constitute a legal Sudoku puzzle.booleanisSolved()Method to test if the currentCellvalues constitute a solved Sudoku puzzle.List<CoordinateMap<Cell>>nonets()Method to get the sub-CoordinateMaps representing the 3x3 boxes (nonets).List<CoordinateMap<Cell>>subMaps()Method to get the sub-CoordinateMaps representing the 9-Cellgroups where the digits 1-9 must appear exactly once.List<CoordinateMap<Cell>>subMapsOf(Cell cell)-
Methods inherited from class ball.util.CoordinateMap
addTableModelListener, asList, clear, column, columns, comparator, containsKey, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, firstKey, get, getColumnClass, getColumnCount, getColumnName, getMax, getMaxX, getMaxY, getMin, getMinX, getMinY, getRowCount, getTableModelListeners, getType, getValueAt, headMap, includes, isCellEditable, lastKey, map, put, put, remove, removeTableModelListener, resize, resize, row, rows, setValueAt, subMap, subMap, tailMap
-
Methods inherited from class java.util.AbstractMap
clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, size, toString, values
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, equals, forEach, get, getOrDefault, hashCode, isEmpty, merge, putAll, putIfAbsent, remove, replace, replace, replaceAll, size
-
-
-
-
Constructor Detail
-
Puzzle
public Puzzle()
Sole constructor.
-
-
Method Detail
-
nonets
public List<CoordinateMap<Cell>> nonets()
Method to get the sub-CoordinateMaps representing the 3x3 boxes (nonets).- Returns:
- The
Listof 3x3 nonetCoordinateMaps.
-
subMaps
public List<CoordinateMap<Cell>> subMaps()
Method to get the sub-CoordinateMaps representing the 9-Cellgroups where the digits 1-9 must appear exactly once. SeeCoordinateMap.rows(),CoordinateMap.columns(), andnonets().- Returns:
- The
Listof Sudoku sub-CoordinateMaps.
-
subMapsOf
public List<CoordinateMap<Cell>> subMapsOf(Cell cell)
Method to get the sub-CoordinateMaps representing the 9-Cellgroups including the argumentCell. SeeCoordinateMap.rows(),CoordinateMap.columns(), andnonets().- Parameters:
cell- The argumentCell.- Returns:
- The
Listof Sudoku sub-CoordinateMaps for the argumentCell. - See Also:
subMaps()
-
isLegal
public boolean isLegal()
Method to test if the currentCellvalues constitute a legal Sudoku puzzle.
-
isSolved
public boolean isSolved()
Method to test if the currentCellvalues constitute a solved Sudoku puzzle.
-
-