avatar
h*e
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)
{

}
avatar
h*e
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);
:
: }

avatar
l*s
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.
avatar
h*e
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.

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。