Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Clight_13
- {
- class Program
- {
- static void Main()
- {
- string userName = "";
- int userAge = 0;
- float userHeight = 0;
- string userProfession = "";
- string menuNumber;
- string colorNumber;
- bool isMenuWorking = true;
- Console.WriteLine("Анкета.\n");
- while (isMenuWorking)
- {
- const string CommandName = "1";
- const string CommandAge = "2";
- const string CommandHeight = "3";
- const string CommandProfession = "4";
- const string CommandInfo = "5";
- const string CommandColors = "6";
- const string CommandExit = "7";
- const string CommandWhiteColor = "1";
- const string CommandRedColor = "2";
- const string CommandGreenColor = "3";
- const string CommandBlueColor = "4";
- Console.WriteLine("Меню:");
- Console.WriteLine($"{CommandName} - Ввести своё имя");
- Console.WriteLine($"{CommandAge} - Ввести свой возраст");
- Console.WriteLine($"{CommandHeight} - Ввести свой рост");
- Console.WriteLine($"{CommandProfession} - Ввести свою профессию");
- Console.WriteLine($"{CommandInfo} - Посмотреть информацию о себе");
- Console.WriteLine($"{CommandColors} - Поменять цвет текста");
- Console.WriteLine($"{CommandExit} - Выход\n");
- Console.Write("Введите номер пункта меню: ");
- menuNumber = Console.ReadLine();
- Console.Clear();
- switch (menuNumber)
- {
- case CommandName:
- Console.Write("Введите своё имя: ");
- userName = Console.ReadLine();
- break;
- case CommandAge:
- Console.Write("Введите свой возраст: ");
- int.TryParse(Console.ReadLine(), out userAge);
- break;
- case CommandHeight:
- Console.Write("Введите свой рост (см): ");
- float.TryParse(Console.ReadLine(), out userHeight);
- break;
- case CommandProfession:
- Console.Write("Введите свою профессию: ");
- userProfession = Console.ReadLine();
- break;
- case CommandInfo:
- Console.WriteLine("Ваша анкета:");
- Console.WriteLine($"Имя: {userName}");
- Console.WriteLine($"Возраст (лет): {userAge}");
- Console.WriteLine($"Рост (см): {userHeight}");
- Console.WriteLine($"Профессия: {userProfession}\n");
- Console.Write($"Для продолжения нажмите любую клавишу.");
- userProfession = Console.ReadLine();
- break;
- case CommandColors:
- Console.Clear();
- Console.WriteLine("Номера цветов:");
- Console.WriteLine($"{CommandWhiteColor} - Белый");
- Console.WriteLine($"{CommandRedColor} - Красный");
- Console.WriteLine($"{CommandGreenColor} - Зелёный");
- Console.WriteLine($"{CommandBlueColor} - Синий\n");
- Console.Write("Введите номер цвета текста: ");
- colorNumber = Console.ReadLine();
- switch (colorNumber)
- {
- case CommandWhiteColor:
- Console.ForegroundColor = ConsoleColor.White;
- break;
- case CommandRedColor:
- Console.ForegroundColor = ConsoleColor.DarkRed;
- break;
- case CommandGreenColor:
- Console.ForegroundColor = ConsoleColor.DarkGreen;
- break;
- case CommandBlueColor:
- Console.ForegroundColor = ConsoleColor.DarkBlue;
- break;
- default:
- Console.WriteLine("Произошла ошибка. Попробуйте ещё раз, для этого нажмите любую клавишу.");
- Console.ReadKey();
- break;
- }
- break;
- case CommandExit:
- isMenuWorking = false;
- break;
- default:
- Console.WriteLine("Необходимо ввести номер пункта меню. Нажмите любую клавишу.");
- Console.ReadKey();
- break;
- }
- Console.Clear();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement