amazon 面经# JobHunting - 待字闺中
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)
{
}
现,只需要加注释说明干什么。 欢迎牛人指点下面的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)
{
}