Advertisement
TwinFrame

Clight_13_Profile

Mar 21st, 2023 (edited)
502
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.05 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Clight_13
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             string userName = "";
  10.             int userAge = 0;
  11.             float userHeight = 0;
  12.             string userProfession = "";
  13.  
  14.             string menuNumber;
  15.             string colorNumber;
  16.  
  17.             bool isMenuWorking = true;
  18.  
  19.             Console.WriteLine("Анкета.\n");
  20.  
  21.             while (isMenuWorking)
  22.             {
  23.                 const string CommandName = "1";
  24.                 const string CommandAge = "2";
  25.                 const string CommandHeight = "3";
  26.                 const string CommandProfession = "4";
  27.                 const string CommandInfo = "5";
  28.                 const string CommandColors = "6";
  29.                 const string CommandExit = "7";
  30.  
  31.                 const string CommandWhiteColor = "1";
  32.                 const string CommandRedColor = "2";
  33.                 const string CommandGreenColor = "3";
  34.                 const string CommandBlueColor = "4";
  35.  
  36.                 Console.WriteLine("Меню:");
  37.                 Console.WriteLine($"{CommandName} - Ввести своё имя");
  38.                 Console.WriteLine($"{CommandAge} - Ввести свой возраст");
  39.                 Console.WriteLine($"{CommandHeight} - Ввести свой рост");
  40.                 Console.WriteLine($"{CommandProfession} - Ввести свою профессию");
  41.                 Console.WriteLine($"{CommandInfo} - Посмотреть информацию о себе");
  42.                 Console.WriteLine($"{CommandColors} - Поменять цвет текста");
  43.                 Console.WriteLine($"{CommandExit} - Выход\n");
  44.                 Console.Write("Введите номер пункта меню: ");
  45.  
  46.                 menuNumber = Console.ReadLine();
  47.  
  48.                 Console.Clear();
  49.  
  50.                 switch (menuNumber)
  51.                 {
  52.                     case CommandName:
  53.                         Console.Write("Введите своё имя: ");
  54.                         userName = Console.ReadLine();
  55.                         break;
  56.                     case CommandAge:
  57.                         Console.Write("Введите свой возраст: ");
  58.                         int.TryParse(Console.ReadLine(), out userAge);
  59.                         break;
  60.                     case CommandHeight:
  61.                         Console.Write("Введите свой рост (см): ");
  62.                         float.TryParse(Console.ReadLine(), out userHeight);
  63.                         break;
  64.                     case CommandProfession:
  65.                         Console.Write("Введите свою профессию: ");
  66.                         userProfession = Console.ReadLine();
  67.                         break;
  68.                     case CommandInfo:
  69.                         Console.WriteLine("Ваша анкета:");
  70.                         Console.WriteLine($"Имя: {userName}");
  71.                         Console.WriteLine($"Возраст (лет): {userAge}");
  72.                         Console.WriteLine($"Рост (см): {userHeight}");
  73.                         Console.WriteLine($"Профессия: {userProfession}\n");
  74.                         Console.Write($"Для продолжения нажмите любую клавишу.");
  75.  
  76.                         userProfession = Console.ReadLine();
  77.                         break;
  78.                     case CommandColors:
  79.                         Console.Clear();
  80.                         Console.WriteLine("Номера цветов:");
  81.                         Console.WriteLine($"{CommandWhiteColor} - Белый");
  82.                         Console.WriteLine($"{CommandRedColor} - Красный");
  83.                         Console.WriteLine($"{CommandGreenColor} - Зелёный");
  84.                         Console.WriteLine($"{CommandBlueColor} - Синий\n");
  85.                         Console.Write("Введите номер цвета текста: ");
  86.  
  87.                         colorNumber = Console.ReadLine();
  88.  
  89.                         switch (colorNumber)
  90.                         {
  91.                             case CommandWhiteColor:
  92.                                 Console.ForegroundColor = ConsoleColor.White;
  93.                                 break;
  94.                             case CommandRedColor:
  95.                                 Console.ForegroundColor = ConsoleColor.DarkRed;
  96.                                 break;
  97.                             case CommandGreenColor:
  98.                                 Console.ForegroundColor = ConsoleColor.DarkGreen;
  99.                                 break;
  100.                             case CommandBlueColor:
  101.                                 Console.ForegroundColor = ConsoleColor.DarkBlue;
  102.                                 break;
  103.                             default:
  104.                                 Console.WriteLine("Произошла ошибка. Попробуйте ещё раз, для этого нажмите любую клавишу.");
  105.                                 Console.ReadKey();
  106.                                 break;
  107.                         }
  108.  
  109.                         break;
  110.                     case CommandExit:
  111.                         isMenuWorking = false;
  112.                         break;
  113.                     default:
  114.                         Console.WriteLine("Необходимо ввести номер пункта меню. Нажмите любую клавишу.");
  115.                         Console.ReadKey();
  116.                         break;
  117.                 }
  118.  
  119.                 Console.Clear();
  120.             }
  121.         }
  122.     }
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement