官术网_书友最值得收藏!

The GameBoard class

Now that we have a way to represent pieces in memory, the next logical step is to create a way to represent an entire board of playing pieces.

The game board is a two-dimensional array of GamePiece objects, and we can build in some additional functionality to allow our code to interact with pieces on the game board by their X and Y coordinates.

The GameBoard class needs to:

  • Store a GamePiece object for each square on the game board
  • Provide methods for code using the GameBoard to update individual pieces, by passing calls through to the underlying GamePiece instances
  • Randomly assign a piece type to a GamePiece
  • Set and clear the "Filled with water" flags on individual GamePieces
  • Determine which pipes should be filled with water, based on their position and orientation, and mark them as filled
  • Return lists of potentially scoring water chains to code using the GameBoard
主站蜘蛛池模板: 离岛区| 卢湾区| 三明市| 侯马市| 乐陵市| 健康| 湖口县| 平顶山市| 宜君县| 河北省| 延寿县| 平乐县| 永登县| 宜君县| 涟源市| 深圳市| 怀化市| 德清县| 滁州市| 新邵县| 洛宁县| 含山县| 肥乡县| 广安市| 景谷| 三台县| 鲁山县| 西和县| 嘉禾县| 昌平区| 德钦县| 蒙城县| 玛曲县| 莆田市| 康定县| 阜新| 河池市| 深水埗区| 南康市| 进贤县| 基隆市|