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(); }
public void The_Game_Should_Print_The_Map_Correctly() { var sut = new ConnectFour(); var expectedMap = new int[6, 7] { { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0 }, { 1, 1, 1, 1, 2, 2, 2 } }; var expectedOutput = "0 0 0 0 0 0 0" + Environment.NewLine + "0 0 0 0 0 0 0" + Environment.NewLine + "0 0 0 0 0 0 0" + Environment.NewLine + "0 0 0 0 0 0 0" + Environment.NewLine + "0 0 0 0 0 0 0" + Environment.NewLine + "1 1 1 1 2 2 2" + Environment.NewLine; sut.LoadMap(expectedMap); Assert.AreEqual(expectedOutput, sut.MapToString()); }