Example #1
0
        public void TestAllOnes()
        {
            var game = new BowlingGameLogic();

            RollMany(20, 1, game);
            Assert.IsTrue(game.GetFinalScore() == 20);
        }
Example #2
0
        static void Main(string[] args)
        {
            BowlingGameLogic game = new BowlingGameLogic();

            for (int i = 1; i < 11; i++)
            {
                Console.WriteLine("Enter the score of the first roll of the Frame " + i);
                int numberOfPinsThatWereHitFirst;
                int.TryParse(Console.ReadLine(), out numberOfPinsThatWereHitFirst);
                game.Roll(numberOfPinsThatWereHitFirst);
                if (numberOfPinsThatWereHitFirst != 10)
                {
                    Console.WriteLine("Enter the score of the second roll of the Frame " + i);
                    int numberOfPinsThatWereHitSecond;
                    int.TryParse(Console.ReadLine(), out numberOfPinsThatWereHitSecond);
                    game.Roll(numberOfPinsThatWereHitSecond);
                    if (numberOfPinsThatWereHitFirst + numberOfPinsThatWereHitSecond == 10)
                    {
                        Console.WriteLine("SPARE!\n");
                    }
                }
                else
                {
                    Console.WriteLine("STRIKE!!!\n");
                }
            }

            Console.WriteLine("\nYour final score is: " + game.GetFinalScore());
            Console.WriteLine(Console.ReadLine());
        }
Example #3
0
        public void TestPerfectGame()
        {
            var game = new BowlingGameLogic();

            RollMany(12, 10, game);

            var score = game.GetFinalScore();

            Assert.IsTrue(score == 300);
        }
Example #4
0
        public void TestStrikeBonus()
        {
            var game = new BowlingGameLogic();

            game.Roll(10); // strike bonus active for next two rolls
            game.Roll(3);
            game.Roll(4);
            RollMany(16, 0, game);
            var score = game.GetFinalScore();

            Assert.IsTrue(score == 17 + 3 + 4);
        }
Example #5
0
        public void TestSpareBonus()
        {
            var game = new BowlingGameLogic();

            game.Roll(5);
            game.Roll(5); // spare bonus is active for next roll
            game.Roll(7);
            game.Roll(3); // spare bonus is active for next roll
            game.Roll(1);
            RollMany(15, 0, game);
            var score = game.GetFinalScore();

            Assert.IsTrue(score == 21 + 7 + 1);
        }
Example #6
0
        public void TestBonusFrameAfterSpear()
        {
            var game = new BowlingGameLogic();

            RollMany(18, 0, game);
            game.Roll(5);
            game.Roll(5);
            // A spear in the last frame gives one bonus roll.
            //
            game.Roll(3);

            var score = game.GetFinalScore();

            Assert.IsTrue(score == 10 + 3);
        }
Example #7
0
        public void TestBonusFrameAfterStrike()
        {
            var game = new BowlingGameLogic();

            RollMany(18, 0, game);
            game.Roll(10);
            // A strike in the last frame gives two bonus rolls.
            //
            game.Roll(5);
            game.Roll(10);

            var score = game.GetFinalScore();

            Assert.IsTrue(score == 10 + 5 + 10);
        }