static void Main(string[] args) { while (true) { Console.WriteLine("1. Игра против Компьютера"); Console.WriteLine("2. Игра против человека"); Console.WriteLine("0. Выход"); string rk = Console.ReadLine(); while (true) { try { switch (rk) { case "1": string temp = GameRun.generateNumber(); Playgame playgame = new Playgame(new Game(temp)); GameRun.playvscomp(playgame); break; case "2": Playgame playgame2 = new Playgame(new Game(GameRun.manualNumberentry())); GameRun.playvsplayer(playgame2); break; case "0": Environment.Exit(0); break; default: Console.Clear(); Console.WriteLine("Неверный выбор"); break; } } catch (GenerateException) { } catch (Exception ex) { if (GameRun.isfinished) { Console.Clear(); Console.WriteLine(ex.Message); Console.ReadKey(); break; } else { Console.WriteLine(ex.Message); } } } } }
public static void playvsplayer(Playgame playgame) { while (true) { Console.WriteLine("Введите ответ"); string answer = Console.ReadLine(); Console.WriteLine(playgame.nextStep(answer)); playgame.nextStep(answer); } }
public static void playvscomp(Playgame playgame) { while (true) { Console.WriteLine($"Введите ответ длинной-{lenghtnumber}"); string answer = Console.ReadLine(); Console.WriteLine(playgame.nextStep(answer)); playgame.nextStep(answer); } }