本文整理汇总了C#中Game.Roll方法的典型用法代码示例。如果您正苦于以下问题:C# Game.Roll方法的具体用法?C# Game.Roll怎么用?C# Game.Roll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game.Roll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Spare
public void Spare()
{
var game = new Game();
game.Roll(5);
game.Roll(5);
game.Roll(1);
Assert.Equal(12, game.Score());
}
示例2: Strike
public void Strike()
{
var game = new Game();
game.Roll(10);
game.Roll(5);
game.Roll(1);
Assert.Equal(22, game.Score());
}
示例3: Game
public void 二回投げて合計値を計算できる()
{
var g = new Game();
g.Roll(3);
g.Roll(2);
Assert.That(g.Score(), Is.EqualTo(5));
}
示例4: Score7Game
public void Score7Game()
{
var game = new Game();
game.Roll(2);
game.Roll(5);
RollPinsSeveralTimes(game, 18, 0);
Assert.AreEqual(7, game.Score());
}
示例5: latterStrike
public void latterStrike()
{
var game = new Game();
game.Roll(3);
game.Roll(6);
game.Roll(10);
game.Roll(5);
game.Roll(1);
Assert.Equal(31, game.Score());
}
示例6: ScoreOneSpareGame
public void ScoreOneSpareGame()
{
var game = new Game();
game.Roll(4);
game.Roll(6);
game.Roll(2);
RollPinsSeveralTimes(game, 17, 0);
Assert.AreEqual(14, game.Score());
}
示例7: TestOneStrike
public void TestOneStrike()
{
Game game = new Game();
game.Roll(10); // strike
game.Roll(3);
game.Roll(4);
for (int i = 0; i < 16; i++)
{
game.Roll(0);
}
Assert.AreEqual(24, game.Score());
}
示例8: TestSingleSpare
public void TestSingleSpare()
{
// Arrange
Game game = new Game();
// Act
RollSpare(game);
game.Roll(3);
for (int i = 0; i < 17; i++)
{
game.Roll(0);
}
// Assert
Assert.AreEqual(16, game.Score());
}
示例9: Main
public static void Main(String[] args)
{
Game aGame = new Game();
aGame.Add("Chet");
aGame.Add("Pat");
aGame.Add("Sue");
Random rand = new Random();
do
{
aGame.Roll(rand.Next(5) + 1);
if (rand.Next(9) == 7)
{
notAWinner = aGame.MarkCurrentAnswerAsIncorrectAndMoveToNextPlayer();
}
else
{
notAWinner = aGame.MarkCurrentAnswerAsCorrectAndMoveToNextPlayer();
}
} while (notAWinner);
}
示例10: Main
public static void Main(String[] args)
{
InputParameters input = ReadInput(args);
for (int i = 0; i < input.Samples; i++)
{
int mySeed = input.Seed + i*313;
CreateFile(i, mySeed, input.Iteration);
Game aGame = new Game(Console.WriteLine, new PlayersController(3));
AnswerController answerController = new AnswerController(aGame.GiveCorrectAnswerAndCheckIfNOTWinner, aGame.wrongAnswer);
aGame.add("Chet");
aGame.add("Pat");
aGame.add("Sue");
try
{
Random rand = new Random(mySeed);
do
{
aGame.Roll(rand.Next(5) + 1);
_notAWinner = answerController.GiveAnswer(rand.Next(9));
} while (_notAWinner);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
CloseStream();
}
}
示例11: RollPinsSeveralTimes
void RollPinsSeveralTimes(Game g, int rollCount, int pinsToKnock)
{
for (int i = 0; i < rollCount; i++)
{
g.Roll(pinsToKnock);
}
}
示例12: Score
public string Score()
{
var game = new Game();
foreach (int roll in _rolls.Select(x => Convert.ToInt32(x)))
{
game.Roll(roll);
}
return game.Score().ToString(CultureInfo.CurrentCulture);
}
示例13: given_a_gutter_game_when_getting_score_then_should_return_0
public void given_a_gutter_game_when_getting_score_then_should_return_0()
{
var game = new Game();
Enumerable.Range(1, 20).ToList()
.ForEach(index => game.Roll(0));
game.Score.Should().Be(0);
}
示例14: TestPerfectGame
public void TestPerfectGame()
{
Game game = new Game();
for (int i = 0; i < 12; i++)
{
game.Roll(10);
}
Assert.AreEqual(300, game.Score());
}
示例15: TestAllOnes
public void TestAllOnes()
{
Game game = new Game();
for (int i = 0; i < 20; i++)
{
game.Roll(1);
}
Assert.AreEqual(20, game.Score());
}