command
module
Version:
v0.0.0-...-cc2c25f
Opens a new window with list of versions in this module.
Published: Aug 23, 2019
License: Apache-2.0
Opens a new window with license information.
Imports: 5
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
15格拼图游戏
描述
- 4*4的拼盘里有16个格子,摆了15个图,1-15
- 这15个图的位置是随机的
- 要求:实现一个拼图游戏
问题
- 拼盘上有16个格子
- 15个拼图块初始位置是随即的
- 通过上下左右可以控制拼图块的移动
- 拼好了就结束,提示成功(1-15按顺序摆在正确的位置)
解决过程
-
设计,实现16个格子的拼盘
-
随机生成15个拼图块
-
读方向键
-
判断成功 不需要
-
重构
- 多文件
- print.go
- keyboard.go
- table.go
- puzzle.go
未优化
- 多文件的测试
- 数据结构分两大块:拼盘和玩一盘的记录
- 流程应该分为游戏准备和游戏过程
总结
tdd解决这个问题时,处理的不够好,设计时应该将准备部分和游戏部分明确分开,
但实际动手时,没有强化这个概念,导致最后写测试例子时颗粒度把握不好,导致进展缓慢
Documentation
¶
There is no documentation for this package.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.