TwinFrame

UserMenu

Jan 11th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Clight_09_consolMenu
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. bool exitApp = true;
  10. bool exitColor = true;
  11. byte numMenu;
  12. byte numColor;
  13. string name = "Uknown";
  14. string age = "Uknown";
  15. string height = "Uknown";
  16. string passUser;
  17. string pass = " ";
  18. byte countPass = 3;
  19.  
  20. Console.WriteLine("Привет, заполни анкету\n \n \n");
  21.  
  22. while (exitApp == true)
  23. {
  24. Console.WriteLine("\nМеню:");
  25. Console.WriteLine("1 - Задать пароль");
  26. Console.WriteLine("2 - Ввести своё имя");
  27. Console.WriteLine("3 - Ввести свой возраст");
  28. Console.WriteLine("4 - Ввести свой рост");
  29. Console.WriteLine("5 - Посмотреть информацию о себе");
  30. Console.WriteLine("6 - Поменять цвет текста");
  31. Console.WriteLine("7 - Выход");
  32. numMenu = Convert.ToByte(Console.ReadLine());
  33.  
  34. switch (numMenu)
  35. {
  36. case 1:
  37. Console.Write("Введите пароль: ");
  38. pass = Console.ReadLine();
  39. break;
  40. case 2:
  41. Console.Write("Введите своё имя: ");
  42. name = Console.ReadLine();
  43. break;
  44. case 3:
  45. Console.Write("Введите своё возраст: ");
  46. age = Console.ReadLine();
  47. break;
  48. case 4:
  49. Console.Write("Введите своё рост: ");
  50. height = Console.ReadLine();
  51. break;
  52. case 5:
  53. if (pass != " ")
  54. {
  55. for (byte i = 0; i < countPass; i++)
  56. {
  57. Console.WriteLine("Введите пароль.\nКоличество оставшихся попыток: " + (countPass - i) + "\n");
  58. passUser = Console.ReadLine();
  59. if (passUser == pass)
  60. {
  61. Console.WriteLine("\n\nИнформация о вас:");
  62. Console.WriteLine($"Имя: {name}\nВозраст: {age}\nРост: {height}\n");
  63. Console.WriteLine("Нажмите любую клавишу для возврата в меню\n\n");
  64. Console.ReadKey();
  65. break;
  66. }
  67. }
  68. }
  69. else
  70. {
  71. Console.WriteLine("Сначала задайте пароль в 1-ом пункте меню");
  72. }
  73. break;
  74. case 6:
  75. exitColor = true;
  76. while (exitColor == true)
  77. {
  78. Console.WriteLine("\nВыберете цвет текста:");
  79. Console.WriteLine("1 - Красный");
  80. Console.WriteLine("2 - Зеленый");
  81. Console.WriteLine("3 - Синий");
  82. Console.WriteLine("4 - Белый");
  83. Console.WriteLine("5 - Выход\n");
  84. numColor = Convert.ToByte(Console.ReadLine());
  85. switch (numColor)
  86. {
  87. case 1:
  88. Console.ForegroundColor = ConsoleColor.Red;
  89. break;
  90. case 2:
  91. Console.ForegroundColor = ConsoleColor.Green;
  92. break;
  93. case 3:
  94. Console.ForegroundColor = ConsoleColor.Blue;
  95. break;
  96. case 4:
  97. Console.ForegroundColor = ConsoleColor.White;
  98. break;
  99. case 5:
  100. exitColor = false;
  101. break;
  102. }
  103. }
  104. break;
  105. case 7:
  106. Console.WriteLine("\nЖдём вас снова!\n\n");
  107. exitApp = false;
  108. break;
  109. }
  110. }
  111. }
  112.  
  113. }
  114. }
Add Comment
Please, Sign In to add comment