当前位置: 首页>>代码示例>>C#>>正文


C# Game.Roll方法代码示例

本文整理汇总了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());
 }
开发者ID:cschrammel,项目名称:BowlingKata,代码行数:8,代码来源:GameTests.cs

示例2: Strike

 public void Strike()
 {
     var game = new Game();
     game.Roll(10);
     game.Roll(5);
     game.Roll(1);
     Assert.Equal(22, game.Score());
 }
开发者ID:cschrammel,项目名称:BowlingKata,代码行数:8,代码来源:GameTests.cs

示例3: Game

        public void 二回投げて合計値を計算できる()
        {
            var g = new Game();
            g.Roll(3);
            g.Roll(2);

            Assert.That(g.Score(), Is.EqualTo(5));
        }
开发者ID:Khanchai,项目名称:BowlingGame,代码行数:8,代码来源:GameTest.cs

示例4: Score7Game

        public void Score7Game()
        {
            var game = new Game();
            game.Roll(2);
            game.Roll(5);
            RollPinsSeveralTimes(game, 18, 0);

            Assert.AreEqual(7, game.Score());
        }
开发者ID:RyanBetker,项目名称:Kata.Bowling,代码行数:9,代码来源:GameTest.cs

示例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());
 }
开发者ID:cschrammel,项目名称:BowlingKata,代码行数:10,代码来源:GameTests.cs

示例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());
        }
开发者ID:RyanBetker,项目名称:Kata.Bowling,代码行数:11,代码来源:GameTest.cs

示例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());
        }
开发者ID:aespinosa,项目名称:BowlingKata,代码行数:14,代码来源:GameTest.cs

示例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());
        }
开发者ID:aespinosa,项目名称:BowlingKata,代码行数:16,代码来源:GameTest.cs

示例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);
        }
开发者ID:pjvds,项目名称:trivia,代码行数:26,代码来源:GameRunner.cs

示例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();
            }
        }
开发者ID:calinilie,项目名称:trivia,代码行数:33,代码来源:GameRunner.cs

示例11: RollPinsSeveralTimes

 void RollPinsSeveralTimes(Game g, int rollCount, int pinsToKnock)
 {
     for (int i = 0; i < rollCount; i++)
     {
         g.Roll(pinsToKnock);
     }
 }
开发者ID:RyanBetker,项目名称:Kata.Bowling,代码行数:7,代码来源:GameTest.cs

示例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);
 }
开发者ID:davidadsit,项目名称:bddtddfitnesse,代码行数:9,代码来源:FinalScore.cs

示例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);
        }
开发者ID:toddmeinershagen,项目名称:Katas,代码行数:9,代码来源:GameTests.cs

示例14: TestPerfectGame

        public void TestPerfectGame()
        {
            Game game = new Game();

            for (int i = 0; i < 12; i++)
            {
                game.Roll(10);
            }

            Assert.AreEqual(300, game.Score());
        }
开发者ID:aespinosa,项目名称:BowlingKata,代码行数:11,代码来源:GameTest.cs

示例15: TestAllOnes

        public void TestAllOnes()
        {
            Game game = new Game();

            for (int i = 0; i < 20; i++)
            {
                game.Roll(1);
            }

            Assert.AreEqual(20, game.Score());
        }
开发者ID:aespinosa,项目名称:BowlingKata,代码行数:11,代码来源:GameTest.cs


注:本文中的Game.Roll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。