h******e 发帖数: 52 | 1 OOD Design 一个mine game, 也就是以前windows里的自带的挖雷游戏。 不需要具体实
现,只需要加注释说明干什么。 欢迎牛人指点下面的design有什么问题。
abstract class GameBase
{
abstract public void startNewGame(int level);
abstract public void endCurrentGame();
abstract public DateTime getTimer();
abstract public void click(int row, int col);
}
class MineGame : GameBase
{
private int userLevel;
private int matrix[,];
private int maxRow;
private int maxCol;
private long timeDuration;
//This will initialize all the need variable like level, matrix
//Preset some of the mines in the matrix
//Go through the matrix to figure out the numbers for the cell which is
not mine
override public void startNewGame(int level)
{
}
//Clean up everything to close the game
override public void endCurrentGame()
{
}
//Get current time duration to show to user
override public DateTime getCurrentTimeDuration()
{
}
//user action
//if matrix[row, col] is mine, call endGame
//else {
if(the number of mines around this cell is equal to this number
uncover all the neighbors and itself
else
uncover itself
}
abstract public void click(int row, int col)
{
} | h******e 发帖数: 52 | 2 自己re 一个
【在 h******e 的大作中提到】 : OOD Design 一个mine game, 也就是以前windows里的自带的挖雷游戏。 不需要具体实 : 现,只需要加注释说明干什么。 欢迎牛人指点下面的design有什么问题。 : abstract class GameBase : { : abstract public void startNewGame(int level); : abstract public void endCurrentGame(); : abstract public DateTime getTimer(); : abstract public void click(int row, int col); : : }
| l******s 发帖数: 3045 | 3 Why do you need an abstract class? What's expecting to extend? If using an
abstract class without any implementation, why not an interface?
Not to challenge, just to ask. | h******e 发帖数: 52 | 4 这里Interface比abstract好,当时考虑的是还有一些可以在baseclass里做,后来没有
想到有那些,也没有时间去改了。 当然这里还有很多要改近的地方。 整个design只有
十分钟时间左右,也不多结果做讨论,我就想知道, 这种考法,面试官想知道什么?
1. OOD基本概念,封装,继承和多态
2. 思考问题的方式,比如怎么样和面试官交流,得到requirement
3. class里面的完整性 - 这个很难如果那个东西你不了解的话。
【在 l******s 的大作中提到】 : Why do you need an abstract class? What's expecting to extend? If using an : abstract class without any implementation, why not an interface? : Not to challenge, just to ask.
|
|