Пример #1
0
        public void ManualGame_TrackScoreStrike()
        {
            var pinsBowled = 10;
            var rollType   = RollType.Strike;

            var game = new PlayGame();

            game.Start(PlayMode.Manual);
            var roll = game.TrackScore(pinsBowled);

            Assert.AreEqual(pinsBowled, roll.PinsBowled, $@"Expected result: {pinsBowled}, Actual result: {roll.PinsBowled}");
            Assert.AreEqual(pinsBowled, game.FrameScore(0), $@"Expected result: {pinsBowled}, Actual result: {game.FrameScore(0)}");
            Assert.AreEqual(rollType, roll.RollType, $@"Expected result: {rollType}, Actual result: {roll.RollType}");
        }
Пример #2
0
        public void ManualGame_BackToBackStrikes()
        {
            var pinsBowled = 10;
            var rollType   = RollType.Strike;

            var game = new PlayGame();

            game.Start(PlayMode.Manual);
            var rollOne = game.TrackScore(pinsBowled);
            var rollTwo = game.TrackScore(pinsBowled);

            Assert.AreEqual(pinsBowled, rollOne.PinsBowled, $@"Expected result: {pinsBowled}, Actual result: {rollOne.PinsBowled}");
            Assert.AreEqual((pinsBowled * 2), game.FrameScore(0), $@"Expected result: {(pinsBowled * 2)}, Actual result: {game.FrameScore(0)}");
            Assert.AreEqual(rollType, rollOne.RollType, $@"Roll One Expected result: {rollType}, Actual result: {rollOne.RollType}");
            Assert.AreEqual(rollType, rollTwo.RollType, $@"Roll Two Expected result: {rollType}, Actual result: {rollTwo.RollType}");
        }
Пример #3
0
        private static void InteractiveGame(string playerName)
        {
            var playService = new PlayGame();
            var frameIndx   = 0;
            var rollCount   = 0;

            playService.Start(Shared.Enums.PlayMode.Interactive);

            if (playService.IsStarted)
            {
                Console.WriteLine($"{playerName} your current score is {playService.GameScore}");
                Console.WriteLine("");
                Console.WriteLine($"Press Enter {playerName} to bowl");
                Console.ReadLine();

                while (!playService.IsFinished)
                {
                    var roll = playService.Bowl();

                    rollCount++;

                    Console.WriteLine($"{playerName} the roll {rollCount} bowled {roll.PinsBowled} pins.");

                    if (roll.RollType == Shared.Enums.RollType.Strike)
                    {
                        Console.WriteLine("You bowled a STRIKE.");
                    }
                    else if (roll.RollType == Shared.Enums.RollType.Spare)
                    {
                        Console.WriteLine("You bowled a Spare.");
                    }

                    Console.WriteLine("");
                    Console.WriteLine($"{playerName} your current frame score is {playService.FrameScore(frameIndx)}");
                    Console.WriteLine("");
                    Console.WriteLine($"Press Enter {playerName} for you next bowl");
                    Console.ReadLine();
                    Console.Clear();
                    Console.WriteLine($"{playerName} your current score is {playService.GameScore}");
                    Console.WriteLine("");

                    if ((rollCount % 2) == 0)
                    {
                        frameIndx++;
                    }
                }

                Console.Clear();
                Console.WriteLine($"{playerName} your final score is {playService.GameScore}");
                Console.WriteLine("");
                Console.WriteLine("");
                Console.WriteLine($"Press Enter {playerName} to end the game.");

                Console.ReadLine();
            }
            else
            {
                Console.WriteLine("Game failed to start.");
                Console.WriteLine("Press Enter to Exit.");
                Console.ReadLine();
            }
        }