static void TakeTurn(ITicTacToe g) { PlayerMark whoturn = g.GetWhoTurn(); bool placed = false; while (!placed) { bool gotX = false; bool gotY = false; int x, y; x = y = 0; Console.WriteLine("Entering Player Move For: {0}", GetMark(whoturn)); while (!gotX) { Console.WriteLine("Enter Column:"); string lineIn = Console.ReadLine(); gotX = int.TryParse(lineIn, out x); } while (!gotY) { Console.WriteLine("Enter Row:"); string lineIn = Console.ReadLine(); gotY = int.TryParse(lineIn, out y); } placed = g.TryPlaceMarkAt(whoturn, x, y); if (!placed) { Console.WriteLine("Invalid Move!"); } } }
void TestMovesExpectWinner(ITicTacToe g, point[] moves, PlayerMark winner) { foreach (point p in moves) { g.TryPlaceMarkAt(g.GetWhoTurn(), p.x, p.y); } Assert.IsTrue(g.IsGameOver()); Assert.AreEqual <PlayerMark>(winner, g.GetWinner()); }
static void PrintBoard(ITicTacToe g) { PlayerMark whoturn = g.GetWhoTurn(); Console.WriteLine("Player {0}'s Turn", GetMark(whoturn)); Console.WriteLine("Board:"); Console.WriteLine(" 0 | 1 | 2 "); for (int row = 0; row < 3; ++row) { Console.WriteLine("{3}: {0} | {1} | {2} ", GetMark(g.GetMarkAt(0, row)), GetMark(g.GetMarkAt(1, row)), GetMark(g.GetMarkAt(2, row)), row); } }