Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace cSharp
- {
- class TestSoft
- {
- public static void ClearBuf(int currentp)
- {
- System.Console.CursorLeft = 0;
- System.Console.CursorTop = currentp -1;
- }
- static void Main(string[] args)
- {
- Console.WriteLine("Тест переключалки");
- Start:
- Console.Write($"\nВведите символ 1: ");
- int symbol = 0;
- int currentPosition = 0;
- try
- {
- symbol = Convert.ToInt32(Console.ReadLine());
- }
- catch (Exception)
- {
- Console.WriteLine("Вы ввели букву! Введите символ!");
- goto Start;
- }
- if (symbol != 1)
- {
- Console.WriteLine("Вы ввели не цифру 1! Введите цифру 1!");
- goto Start;
- }
- currentPosition = Console.CursorTop;
- Console.WriteLine($"\nПоздравляем! Ваша цифра {symbol}!))");
- Console.WriteLine("\nПовторить выполнение?");
- Console.WriteLine("[Да]");
- Console.WriteLine("Нет");
- bool WhileCycle = true;
- bool ExitFlag = false;
- while (WhileCycle)
- {
- ConsoleKeyInfo ck = Console.ReadKey();
- switch (ck.Key)
- {
- case ConsoleKey.DownArrow:
- Console.CursorVisible = false;
- ClearBuf(currentPosition);
- Console.ForegroundColor = ConsoleColor.Red;
- Console.Write($"\nВведите символ 1: {symbol}");
- Console.WriteLine($"\nПоздравляем! Ваша цифра {symbol}!))");
- Console.WriteLine("\nПовторить выполнение?");
- Console.WriteLine("Да");
- Console.WriteLine("[Нет]");
- ExitFlag = true;
- break;
- case ConsoleKey.UpArrow:
- Console.CursorVisible = false;
- ClearBuf(currentPosition);
- Console.ForegroundColor = ConsoleColor.Green;
- Console.Write($"\nВведите символ 1: {symbol}");
- Console.WriteLine($"\nПоздравляем! Ваша цифра {symbol}!))");
- Console.WriteLine("\nПовторить выполнение?");
- Console.WriteLine("[Да]");
- Console.WriteLine("Нет");
- ExitFlag = false;
- break;
- case ConsoleKey.Enter:
- if (ExitFlag)
- { WhileCycle = false; }
- else
- {
- Console.Clear();
- goto Start;
- }
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement