コード例 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("********************");
            Console.WriteLine("* Tic-Tac-Toe Game *");
            Console.WriteLine("********************");
            var game = new TicTacToe();

            Console.WriteLine("The cell numbers for the game are shown below.");
            game.Draw();
            Play(game);
        }
コード例 #2
0
        static void Play(TicTacToe game)
        {
            bool playAgain = true;

            while (playAgain)
            {
                game.DrawBlank();
                game.PlayTurn();

                bool invalidInput = true;
                while (invalidInput)
                {
                    try
                    { Console.WriteLine("Would you like to play again? (y|n)");
                      char again = char.Parse(Console.ReadLine());
                      if (again == 'y')
                      {
                          invalidInput = false;
                      }

                      else if (again == 'n')
                      {
                          playAgain    = false;
                          invalidInput = false;
                          Console.WriteLine("Thank you for playing");
                      }
                      else
                      {
                          Console.WriteLine("Invalid Input. Playing again");
                      } }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"Error: {ex.Message}. Try again");
                    }
                }
            }
        }
コード例 #3
0
 static void Play(TicTacToe game)
 {
     Console.WriteLine($"This feature is not yet implemented");
 }