本文整理汇总了C#中IRenderable.Read方法的典型用法代码示例。如果您正苦于以下问题:C# IRenderable.Read方法的具体用法?C# IRenderable.Read怎么用?C# IRenderable.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRenderable
的用法示例。
在下文中一共展示了IRenderable.Read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeginGame
/// <summary>
/// Method that is responsible for communication between the user and the engine.
/// Handles user input and outputs game response.
/// </summary>
private void BeginGame(IRenderable render)
{
ScoreBoard scoreBoard = new ScoreBoard();
render.PrintField(this.gameField.GetFieldNumbers());
bool gameIsFinished = false;
int moves = 0;
string inputCommand = render.Read("give me command: ").Trim();
while (inputCommand != "exit")
{
switch (inputCommand)
{
case "top":
render.PrintScoreboard(scoreBoard.Scores());
break;
case "restart":
this.StartNewGame(render, true);
break;
default:
moves = MoveNumberIfValid(render, moves, inputCommand);
break;
}
render.PrintField(this.gameField.GetFieldNumbers());
gameIsFinished = this.gameField.IsSolved();
if (gameIsFinished)
{
string message = string.Format("Congratulations! You won the game in {0} moves.", moves);
render.Write(message);
this.AddUserToScoreBoard(scoreBoard, moves, render);
moves = 0;
this.StartNewGame(render);
}
inputCommand = render.Read("give me command: ").Trim();
}
}
示例2: AddUserToScoreBoard
/// <summary>
/// Adds user to scoreboard, asking his name and getting his score.
/// </summary>
/// <param name="score">Number of moves.</param>
private void AddUserToScoreBoard(ScoreBoard scoreBoard, int score, IRenderable render)
{
string name = render.Read("Please enter your name for the top scoreboard: ");
scoreBoard.Add(name, score);
}