Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Comp211 HW11  Supporting Code Details

Core Data Structures


Image Added

 The main data structures are represented by 3 interfacesby only a few interfaces:

  • ICell --  a single square on the Sudoku board.  
    • A cell has a set of integer values, which are accessible either as a HashSet<Integer> or as an array of integers. 
    • A cell also has a collection (Vector<ICell>) of ICellSets to which it belongs.   These are the cell's row, column and block, in that order.
      • Don't forget that the cell is also a member of every ICellSet that it references.  
    • A cell can be in one of three logical states:
      • Empty - there are no values contained in the cell.   This corresponds to the situation where the board is unsolvable because a cell has no possible value.
      • Wiki Markup
        _Solved_ \- the cell contains exactly one value.&nbsp;&nbsp; +If and only if you know for sure that the cell is in this state+, then the single value can be accessed as {{aCell.getValueArray()\[0\]}}.
      • Unsolved - the cell contains multiple possible values.   At most, a cell could contain order*order values.
    • Cell is a concrete implementation of ICell.
    • An ICell accepts an ICellVisitor which has cases for each of the 3 logical states, described above.
      • The ACellVisitor class is an abstract convenience class that provide a default return value for any cases that the developer does not which to override.   There is no requirement to use this class, though it may simplify certain code. 
  • ICellSet -- A collection of ICells.   that represents a row, column or block. 
    •  For convenience sake, the cells are in a distinct order (i.e. left-to right for a row) and thus each cell is addressable by an index value.
    •  

...

    • .
    •  An ICellSet is Iterable which means that it can be used in for-each loops.
  • Wiki Markup
    {\[Board}} \-\- A set of 3 Vector<ICellSet>'s where each element of the vector is an&nbsp;{{ICellSet}}.&nbsp;&nbsp; These vectors represent the entire set of&nbsp;rows, columns or blocks&nbsp;in a game.&nbsp;&nbsp;&nbsp;&nbsp;

Utility Data Structures



Model-View-Controller Architecture

...