Example #1
0
 static void Main(string[] args)
 {
     while (chooseInput)
     {
         //choose to play a human or ai
         Console.WriteLine("Welcome to tic-tac-toe!");
         Console.WriteLine("\nWould like you to play againts a Friend or AI? \nEnter: 1 (for Friend)\nEnter: 2 (for AI)");
         try
         {
             int choice = Convert.ToInt32(Console.ReadLine());
             Console.WriteLine();
             if (choice == 1)
             {
                 Console.WriteLine("You chose to play against another player on the same computer");
                 PlayHuman humanGame = new PlayHuman();
                 humanGame.PlayAHuman();
                 chooseInput = false;
             }
             else if (choice == 2)
             {
                 Console.WriteLine("You chose to play against the AI");
                 PlayAI aiGame = new PlayAI();
                 aiGame.PlayAIMatch();
                 chooseInput = false;
             }
             else
             {
                 Console.WriteLine("Please Enter either a 1 or a 2\n");
             }
             //when the game is over, ask if they want to play again
             if (chooseInput == false)
             {
                 playAgain();
             }
         }
         catch
         {
             Console.WriteLine("Please Enter either a 1 or a 2\n");
         }
     }
 }