indexing description: "Captures commonality among the different kinds of cells or" ; "locations in the Stooge system. A cell can be occupied by a" ; "puzzle piece and may know its immediate neighbors." class ROOM_CELL inherit PUZZLE_COMPONENT creation -- Eiffel kludge. This isn't a deferred class 'cause it doesn't -- have any deferred routines, but I really don't want anyone to -- create an instance. This empty creation clause will prevent such -- dastardly behavior. feature{NONE} init( rm : like room ; c, r : INTEGER ) is -- Do some generic initialization do room := rm row := r column := c ensure room = rm row = r column = c end feature occupied : BOOLEAN -- Am I currently occupied? room : ROOM -- The room I'm a part of. row, column : INTEGER -- My grid coordinates. vacate is -- My 'occupant' is leaving. do occupied := False end occupy( p : like occupant ) is require -- not occupied -- Need to eventually make a decision as to whether cells in this system -- can have more than one occupant. Right now I can't maintain the -- above precondition 'cause snakes and bridges occasionally can occupy the -- same space. do occupied := True occupant := p ensure occupied occupant = p end occupant : PIECE -- My current occupant if any. -- require occupied north, south, east, west, northwest, northeast, southwest, southeast : like Current -- All the neighbors I might need. set_north( c : like Current ) is -- Set my northern neighbor. do north := c ensure north = c end set_northeast( c : like Current ) is -- Set my northeastern neighbor. do northeast := c ensure northeast = c end set_northwest( c : like Current ) is -- Set my northwestern neighbor. do northwest := c ensure northwest = c end set_east( c : like Current ) is -- Set my eastern neighbor. do east := c ensure east = c end set_west( c : like Current ) is -- Set my western neighbor. do west := c ensure west = c end set_south( c : like Current ) is -- Set my southern neighbor. do south := c ensure south = c end set_southeast( c : like Current ) is -- Set my southeastern neighbor. do southeast := c ensure southeast = c end set_southwest( c : like Current ) is -- Set my southwestern neighbor. do southwest := c ensure southwest = c end end