Пример #1
0
        public static void Main(String[] args)
        {
            InputParameters input = ReadInput(args);

            for (int i = 0; i < input.Samples; i++)
            {
                int mySeed = input.Seed + i*313;
                CreateFile(i, mySeed, input.Iteration);

                Game aGame = new Game(Console.WriteLine, new PlayersController(3));
                AnswerController answerController = new AnswerController(aGame.GiveCorrectAnswerAndCheckIfNOTWinner, aGame.wrongAnswer);

                aGame.add("Chet");
                aGame.add("Pat");
                aGame.add("Sue");
                try
                {
                    Random rand = new Random(mySeed);

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

                        _notAWinner = answerController.GiveAnswer(rand.Next(9));
                    } while (_notAWinner);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
                CloseStream();
            }
        }
Пример #2
0
        public void RunGame(TextWriter writer, int seed)
        {
            Game aGame = new Game(writer);

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

            aGame.StartGame();

            Random rand = new Random(seed);

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

                if (rand.Next(9) == 7)
                {
                    notAWinner = aGame.wrongAnswer();
                }
                else
                {
                    notAWinner = aGame.wasCorrectlyAnswered();
                }
            } while (notAWinner);
        }
Пример #3
0
        static void Main(string[] args)
        {
            var game = new Game();
            game.add("Player 1");
            game.add("Player 2");
            game.add("Player 3");
            bool notAWinner;
            Random rand = new Random(1);

            do
            {

                game.roll(rand.Next(5) + 1);

                if (rand.Next(9) == 7)
                {
                    notAWinner = game.wrongAnswer();
                }
                else
                {
                    notAWinner = game.wasCorrectlyAnswered();
                }

            } while (notAWinner);
            Console.Read();
        }
Пример #4
0
        public static void PlayTheGame()
        {
            Random rand  = new Random();
            Game   aGame = new Game();

            Console.WriteLine("\n\n--- Trivia Game ---");

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

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

                if (rand.Next(9) == 7)
                {
                    notAWinner = aGame.wrongAnswer();
                }
                else
                {
                    notAWinner = aGame.wasCorrectlyAnswered();
                }
            } while (notAWinner);
        }
        public static void main(String[] args)
        {
            Game aGame = new Game();

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

            //Random rand = new Random();       Original Code
            // Creates not random series. Take 4711, 0815, 42, etc. to be time independent
            Random rand = new Random(4711);

            do
            {

                aGame.roll(rand.Next(5) + 1);

                if (rand.Next(9) == 7)
                {
                    notAWinner = aGame.wrongAnswer();
                }
                else
                {
                    notAWinner = aGame.wasCorrectlyAnswered();
                }

            } while (notAWinner);
        }
Пример #6
0
        public static void Main(String[] args)
        {
            Game aGame = new Game();

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

            Random rand = new Random();

            do
            {

                aGame.roll(rand.Next(5) + 1);

                if (rand.Next(9) == 7)
                {
                    notAWinner = aGame.wrongAnswer();
                }
                else
                {
                    notAWinner = aGame.wasCorrectlyAnswered();
                }

            } while (notAWinner);
        }
Пример #7
0
        public static void Go(Random random)
        {
            Random rand = random;
            Game aGame = new Game();

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

            do
            {

                aGame.roll(rand.Next(5) + 1);

                if (rand.Next(9) == 7)
                {
                    notAWinner = aGame.wrongAnswer();
                }
                else
                {
                    notAWinner = aGame.wasCorrectlyAnswered();
                }

            } while (notAWinner);
        }
Пример #8
0
        public void GameIsPlayableWithTwoPlayers()
        {
            var myGame = new Game();

            myGame.add("player one");
            myGame.add("player two");

            Assert.True(myGame.isPlayable());
        }
Пример #9
0
        public void GameIsPlayableWith2Players()
        {
            var game = new Game();

            game.add("Player 1");
            game.add("Player 2");

            Assert.That(game.isPlayable(), Is.True);
        }
Пример #10
0
        public void GameIsNotPlayableWithMoreThan5Players()
        {
            var myGame = new Game();

            for (int i = 0; i <= 4; i++)
            {
                myGame.add("player " + i);
            }

            Assert.Throws<IndexOutOfRangeException>(() => { myGame.add("I crash"); });
        }
Пример #11
0
        public void BasicRuleTest()
        {
            var game = new Game();

            Check.That(game.isPlayable()).IsFalse();

            game.add("one");

            Check.That(game.isPlayable()).IsFalse();

            game.add("two");

            Check.That(game.isPlayable()).IsTrue();

            Check.That(game.howManyPlayers()).IsEqualTo(2);
        }
Пример #12
0
        public void MyGameHasOnePlayerAfterAddingOnePlayer()
        {
            var myGame = new Game();

            myGame.add("myPlayer");

            Assert.AreEqual(myGame.howManyPlayers(), 1);
        }
Пример #13
0
        public void ReturnsNumberOfPlayers()
        {
            var game = new Game();

            game.add("Player 1");

            Assert.That(game.howManyPlayers(), Is.EqualTo(1));
        }
Пример #14
0
        public void GameIsNotPlayableWithOnePlayer()
        {
            var myGame = new Game();

            myGame.add("player one");

            Assert.False(myGame.isPlayable());
        }
Пример #15
0
        private static void PlayFakeGame()
        {
            var game = new Game();
            game.add("Andreas");
            game.add("Kjersti");
            game.add("Kim");

            bool gameIsrunning = true;

            while (gameIsrunning)
            {
                game.roll(_helper.Throw());

                if (_helper.Answer())
                    gameIsrunning = game.wasCorrectlyAnswered();
                else
                    gameIsrunning = game.wrongAnswer();
            }
            Console.WriteLine("-------------------");
        }
Пример #16
0
        public Game StartGame(Action<string> eventHandler, IPlayersController playersController, params string[] players)
        {
            if (playersController == null)
                playersController = new DummyPlayersContoller();

            Game game = new Game(eventHandler, playersController);
            foreach (var player in players)
            {
                game.add(player);
            }
            return game;
        }
Пример #17
0
        public void outputs_player_name_and_number_when_added()
        {
            _game.add("Jim");
            _game.add("Bones");

            Assert.That(_stream.ToString(), Is.EqualTo(
                            "Jim was added\n" +
                            "They are player number 1\n" +
                            "Bones was added\n" +
                            "They are player number 2\n"));
        }
Пример #18
0
 public void GameIsNotPlayableWith1Player()
 {
     var game = new Game();
     game.add("Player 1");
     Assert.That(game.isPlayable(), Is.False);
 }
Пример #19
0
        public void CanAddPlayer()
        {
            var game = new Game();

            Assert.That(game.add("Player"), Is.True);
        }
Пример #20
0
 private static Game InitBasicGame()
 {
     var game = new Game();
     game.add("one");
     game.add("two");
     return game;
 }