示例#1
0
        static void Main(string[] args)
        {
            int inputOption = 0;

            Console.WriteLine($"Hello there, welcome to a Bowling game!\nPlease select one of the following:\n1) Enter the frames manually\n2) Auto generated values\nPlease select and press Enter to start");
            string result = Console.ReadLine();

            bool isManual = Int32.TryParse(result, out inputOption) ? inputOption == 1 : false;

            ScoreCard scoreCard = ScoreCard.GenerteEmptyScoreCards();

            // run as long as the game runs
            while (Game.IsEligibleForAnotherTry(scoreCard))
            {
                Tuple <int, int> tries = GetNextFrame(isManual, scoreCard);
                if (tries == null)
                {
                    break;
                }

                try
                {
                    PrintInformation($"Try1 {tries.Item1}, Try2: {tries.Item2}");

                    scoreCard = Game.RollNewFrame(scoreCard, tries.Item1, tries.Item2);

                    if (tries.Item1 == BowlingGameExtenstions.NUM_OF_PINS)
                    {
                        PrintInformation("Strike!!! Well done!");
                    }

                    Console.WriteLine($"The current score is: {Game.GetScore(scoreCard)}.");
                }
                catch (Exception ex)
                {
                    PrintError($"An error occurred: {ex.Message}");
                }
            }

            if (Game.GetScore(scoreCard) == BowlingGameExtenstions.NUM_OF_PINS * 30)
            {
                PrintInformation("*** You are a the KING. Big Lebowski - behind you!");
            }

            Console.WriteLine($"\nThe game's frames were (score {Game.GetScore(scoreCard)}):\n{scoreCard.DisplayScoreCard()}\n\nPress Enter to exit, goodbye..");
            Console.ReadLine();
        }