Next / Previous / Contents / Shipman's homepage

48. class Cell: One location for a character

Each instance of this class represents one location in the puzzle where a letter may go. Each cell's .text attribute may contain one clue letter, or UNK_CELL if there is no clue letter there. Clues are uppercased for the convenience of the person preparing the puzzle file. Here is the interface:

kkck
# - - - - -   c l a s s   C e l l

class Cell(object):
    '''Represents one character position of the puzzle.

      Exports:
        Cell ( coord, text ):
          [ (coord is a cell location as a Coord instance) and
            (text is a clue character, or UNK_CELL if the content
            of this cell is not initially known) ->
              return a new Cell instance with that location and
              text, and no associated slots ]
        .coord:      [ as passed to constructor, read-only ]
        .text:       [ as passed to constructor, read-only, uppercased ]
        .addSlot ( slot ):
          [ slot is a Slot instance that intersects self ->
              self  :=  self with slot added to its list of
                  associated slots ]
        .genSlots():
          [ generate the slots associated with self as a sequence
            of Slot instances, if any ]

      State/Invariants:
        .__slotList:
          [ a list of the Slot instances that intersect self,
            if any ]
    '''