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

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
主站蜘蛛池模板: 信宜市| 县级市| 赤壁市| 金山区| 利辛县| 泰来县| 凌海市| 原平市| 隆昌县| 柳江县| 洪洞县| 永平县| 岳阳县| 长岭县| 开远市| 济阳县| 吴桥县| 武乡县| 旺苍县| 香河县| 四平市| 资溪县| 崇文区| 扬中市| 枝江市| 徐水县| 古丈县| 伊通| 武强县| 浦东新区| 肥城市| 东安县| 静海县| 长丰县| 莒南县| 姜堰市| 白沙| 东兰县| 蓬莱市| 宝应县| 疏附县|