why does a safe tile need to know tis neighbors
A SafeTile
is a field without a bomb in any of its neighbor fields. By the rules of "mine sweeper" all connected safe and neighbor fields are uncovered when a safe field is hit.
By having the SafeTile
knowing its neighbors (which are either of class SafeTile
too or of class NeighborTile
, but never bombs) the current SafeTile
can call the coverUp()
method on its neigbors. Any neighbor which is a SafeTile
itself will also propagate the call to its neighbors recursively, causing a chain reaction.
keep in mind that my quick shot causes an infinite loop...
and what would be the meaning of cover up?
The method coverUp()
is meant to be called by the User Interface (UI) to trigger the state change from "unknown" to "visited". Obviously the subclasses of Tile
will behave differently when this method is called on them.