Ejemplo n.º 1
0
        public void When_Player1_Has_4_Vertical_The_Game_Should_End(int player, int[,] expectedMap)
        {
            var sut = new ConnectFour();

            sut.LoadMap(expectedMap);

            Assert.AreEqual(true, sut.HasWon(sut.Player1));
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var game = new ConnectFour();

            Console.Write(game.MapToString());

            var mapIsFull = false;

            do
            {
                Console.Write("Player 1: ");
                int playerMoveColumn = int.Parse(Console.ReadLine());
                game.Move(game.Player1, playerMoveColumn - 1);
                Console.Write(game.MapToString());

                if (game.HasWon(game.Player1))
                {
                    Console.WriteLine("Player 1 has won!");
                    break;
                }

                Console.Write("Player 2: ");
                playerMoveColumn = int.Parse(Console.ReadLine());
                game.Move(game.Player2, playerMoveColumn - 1);
                Console.Write(game.MapToString());

                if (game.HasWon(game.Player2))
                {
                    Console.WriteLine("Player 2 has won!");
                    break;
                }

                mapIsFull = game.MapIsFull();

                if (mapIsFull)
                {
                    Console.WriteLine("no winner situation!");
                    break;
                }
            } while (!mapIsFull);

            Console.ReadLine();
        }