static void Main(string[] args) { TTTLogic ttt = new TTTLogic(Program.OnError); int x; int y; TTTLogic.boardfull check = TTTLogic.boardfull.boardisnotfull; while (true) { draw(ttt); do { Console.WriteLine("Enter your X position: "); x = Convert.ToInt32(Console.ReadLine()); check = ttt.Checkfull(); } while (!TTTLogic.IsValidCol(x)); do { Console.WriteLine("Enter your Y position: "); y = Convert.ToInt32(Console.ReadLine()); } while (!TTTLogic.IsValidRow(y)); // it is guaranteed that x and y are valid rows/columns, or else the loops wouldn't have exited ttt.placingpiece(x, y); if (ttt.state() != TTTLogic.WhoWon.StillPlaying) { Console.WriteLine("The result of the game was: " + ttt.state().ToString()); break; } check = ttt.Checkfull(); if (check == TTTLogic.boardfull.boardisfull) { // we're full! Console.WriteLine("squares full!!"); break; } } }
static void Main(string[] args) { TTTLogic ttt = new TTTLogic(Program.OnError); int x; int y; int check = 0; while (true) { draw(ttt); do { Console.WriteLine("Enter your X position: "); x = Convert.ToInt32(Console.ReadLine()); check = TTTLogic.Checkfull(); } while (!TTTLogic.IsValidCol(x) && check != 1 && check != -1); do { Console.WriteLine("Enter your Y position: "); y = Convert.ToInt32(Console.ReadLine()); check = TTTLogic.Checkfull(); } while (!TTTLogic.IsValidRow(y) && check != 1 && check != -1); if (check == 1) { Console.WriteLine("squares not full"); } else { Console.WriteLine("squares full!!"); } // it is guaranteed that x and y are valid rows/columns, or else the loops wouldn't have exited ttt.placingpiece(x, y); } }