Exemple #1
0
        public static void Main(String[] args)
        {
            var triviaGame = new TriviaGame();

            triviaGame.AddPlayer("Chet");
            triviaGame.AddPlayer("Pat");
            triviaGame.AddPlayer("Sue");

            var random = (args.Length == 0 ? new WrappedRandom() : new WrappedRandom(args[0].GetHashCode()));
            var turnDie = new NSidedDie(6, random);

            var gameRunner = new GameRunner();

            gameRunner.PlayGame(triviaGame, turnDie, new QuestionAnswerer(random));
        }
Exemple #2
0
        public void PlayGame(TriviaGame triviaGame, NSidedDie turnDie, QuestionAnswerer questionAnswerer)
        {
            bool hasNotWon;

            do
            {
                triviaGame.TakeTurn(turnDie.RollDie());

                var isCorrectAnswer = questionAnswerer.GetIsCorrectAnswer();
                if (isCorrectAnswer)
                {
                    hasNotWon = triviaGame.HandleCorrectAnswer();
                }
                else
                {
                    hasNotWon = triviaGame.SendPlayerToPenaltyBoxAndEndTurn();
                }
            } while (hasNotWon);
        }