public static void Main(string[] args) { //Directory code while (true) { int directory = 0; Console.WriteLine("(0) Exit\n(1) Phallic Measurement\n(2) Tic-Tac-Toe\n(3) Play Ventura Highway\n(4) Prime Number Detector\n(5) www.Privateeyeri.com\n(6) Jacks Mom\n(7) Real Half Birthday Calculator\n(8) Rock Paper Scissors\n(9) Advance Rock Paper Scissors"); Console.Write("Type the number of the program to execute: "); try { directory = Convert.ToInt32(Console.ReadLine()); } catch (System.Exception) { Console.WriteLine("\nError: Please input an integer"); Console.ReadKey(); Console.Clear(); Main(null); } switch (directory) { //Exit case 0: System.Environment.Exit(1); break; //Phallic Measurement case 1: try { AllPrograms.PhallicMeasurement(); } catch (System.Exception ex) { Console.WriteLine("\nError: " + ex.Message); } break; //Tic-Tac-Toe case 2: try { TicTacToe.TicTacToeGame(); } catch (System.Exception ex) { Console.WriteLine("\nError: " + ex.Message); } break; //Ventura Highway case 3: AllPrograms.VenturaHighway(); break; //Prime Number Detector case 4: try { AllPrograms.IsPrimeNumber(); } catch (System.Exception ex) { Console.WriteLine("\nError: " + ex.Message); } break; //Privateeyeri case 5: System.Diagnostics.Process.Start("cmd", "/c start https://privateeyeri.com/index.html#"); break; //Jacks Mom case 6: try { AllPrograms.JackMom(); } catch (System.Exception) { Console.WriteLine("\nError: Shake it like a polaroid picture"); } break; //Real Half Birthday Calculator case 7: try { AllPrograms.RealHalfBirthday(); } catch (System.Exception ex) { Console.WriteLine("\nError: " + ex.Message); } break; //Rock Paper Scissors case 8: try { RockPaperScissors.play(); } catch (System.Exception ex) { Console.WriteLine("\nError: " + ex.Message); } break; //Advanced Rock Paper Scissors case 9: try { AllPrograms.BetterRPS(); } catch (System.Exception ex) { Console.WriteLine("\nError: " + ex.Message); } break; default: Console.Write("\nEnter a valid number."); break; } //Wait to see result Console.ReadKey(); Console.Clear(); } }
static public void TicTacToeGame() { TicTacToe ticAr = new TicTacToe(); Random rnd = new Random(); string xo = "neither"; //Instructions Console.WriteLine("\nInstructions:\nDetermine who will be player X and who will be player O. When it is your turn, enter coordinate spaces with 0,0 being\nthe top left and 2,2 being the bottom right. Make sure you enter your coordinates in the correct format.\n"); //Who will go first int turn = rnd.Next(1, 3); switch (turn) { case 1: turn = 1; break; case 2: turn = 2; break; } //Initial Drawing Console.WriteLine(" " + ticAr.spaces[0, 0] + " | " + ticAr.spaces[0, 1] + " | " + ticAr.spaces[0, 2] + "\n -----------\n" + " " + ticAr.spaces[1, 0] + " | " + ticAr.spaces[1, 1] + " | " + ticAr.spaces[1, 2] + "\n -----------\n" + " " + ticAr.spaces[2, 0] + " | " + ticAr.spaces[2, 1] + " | " + ticAr.spaces[2, 2]); while (true) { //Input while (true) { if (turn == 1) { xo = "X"; Console.Write("Player X: "); string input = Console.ReadLine(); string[] pos = input.Split(','); int posX = Convert.ToInt32(pos[0]); int posY = Convert.ToInt32(pos[1]); //Check if spot is available for X if (ticAr.spaces[posY, posX] == " ") { ticAr.spaces[posY, posX] = "X"; turn = 2; break; } else { Console.WriteLine("That space is taken, choose another space.\n"); } } else { xo = "O"; Console.Write("Player O: "); string input = Console.ReadLine(); string[] pos = input.Split(','); int posX = Convert.ToInt32(pos[0]); int posY = Convert.ToInt32(pos[1]); //Check if spot is available for O if (ticAr.spaces[posY, posX] == " ") { ticAr.spaces[posY, posX] = "O"; turn = 1; break; } else { Console.WriteLine("That space is taken, choose another space.\n"); } } } //Initial Drawing Console.WriteLine(" " + ticAr.spaces[0, 0] + " | " + ticAr.spaces[0, 1] + " | " + ticAr.spaces[0, 2] + "\n -----------\n" + " " + ticAr.spaces[1, 0] + " | " + ticAr.spaces[1, 1] + " | " + ticAr.spaces[1, 2] + "\n -----------\n" + " " + ticAr.spaces[2, 0] + " | " + ticAr.spaces[2, 1] + " | " + ticAr.spaces[2, 2]); //Check if win for (int i = 0; i <= 2; i++) { if (ticAr.spaces[i, 0] == xo && ticAr.spaces[i, 1] == xo && ticAr.spaces[i, 2] == xo) { Win(xo); } else if (ticAr.spaces[0, i] == xo && ticAr.spaces[1, i] == xo && ticAr.spaces[2, i] == xo) { Win(xo); } else if ((ticAr.spaces[0, 0] == xo && ticAr.spaces[1, 1] == xo && ticAr.spaces[2, 2] == xo) || (ticAr.spaces[2, 0] == xo && ticAr.spaces[1, 1] == xo && ticAr.spaces[0, 2] == xo)) { Win(xo); } } } }