示例#1
0
        public static void Main(String[] args)
        {
            Random rand = new Random();
            if (args.Length == 1)
            {
                rand = new Random(Convert.ToInt32(args[0]));
            }

            Game aGame = new Game();

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

            do
            {
                aGame.Roll(rand.Next(5) + 1);

                if (rand.Next(9) == 7)
                {
                    aGame.WrongAnswer();
                }
                else
                {
                    isWinnerDetermined = !aGame.WasLoser();
                }
            }
            while (!isWinnerDetermined);
        }
示例#2
0
        public static void Main(String[] args)
        {
            var aGame = new Game(Console.Out);
            aGame.Add("Chet");
            aGame.Add("Pat");
            aGame.Add("Sue");

            var random = new Random();

            Run(aGame, random);
            Console.ReadLine();
        }
示例#3
0
        public static void Run(Game game, Random random)
        {
            do
            {
                game.Roll(random.Next(5) + 1);

                if (random.Next(9) == 7)
                {
                    notAWinner = game.WrongAnswer();
                }
                else
                {
                    notAWinner = game.WasCorrectlyAnswered();
                }
            } while (notAWinner);
        }
示例#4
0
        public static void Main(string[] args)
        {
            var aGame = new Game();
            var rand = new Random();

            aGame.GetAnswerForQuestion = q => rand.Next(9);

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

            aGame.Start();

            while (!Game.IsFinished)
            {
                aGame.PlayTurn(rand.Next(5) + 1);
            }
        }