Advertisement
LeRoY_Go

Untitled

Jun 14th, 2020
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.75 KB | None | 0 0
  1. cusing System;
  2.  
  3. namespace ConsoleApp3
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string[] fullName = { "Гришин Аверьян Вячеславович", "Гурьев Ермак Альвианович", "Уварова Инна Оскаровна", "Комиссарова Нора Лукьяновна", "Гордеева Герда Еремеевна" };
  10. string[] post = { "Специалист", "Специалист", "Старший специалист", "Руководитель группы", "Начальник отдела" };
  11. string userInputFullName;
  12. while (true)
  13. {
  14.  
  15. Console.WriteLine("1 - добавить досье\n2 - вывести все досье\n3 - удалить досье\n4 - поиск по фамилии\n5 - выход");
  16. Console.Write("Введите команду: ");
  17. string userInput = Console.ReadLine();
  18. Console.Clear();
  19. switch (userInput)
  20. {
  21. case "1":
  22. AddDossier(ref fullName, ref post, out userInputFullName);
  23. break;
  24. case "2":
  25. ShowDossier(fullName, post);
  26. break;
  27. case "3":
  28. DeleteDossier(ref fullName, ref post);
  29. break;
  30. case "4":
  31. DossierSearch(ref fullName, ref post, out userInputFullName);
  32. break;
  33. case "5":
  34. Environment.Exit(50);
  35. break;
  36.  
  37. }
  38. Console.Clear();
  39. }
  40. }
  41. static void AddDossier(ref string[] fullName, ref string[] post, out string userInputFullName)
  42. {
  43. string[] tempFullName = new string[fullName.Length + 1];
  44. Console.Write("Введите фамилию: ");
  45. string userInputSurname = Console.ReadLine();
  46. Console.Write("Введите имя: ");
  47. string userInputName = Console.ReadLine();
  48. Console.Write("Введите отчество: ");
  49. string userInputPatronymic = Console.ReadLine();
  50. userInputFullName = userInputSurname + " " + userInputName + " " + userInputPatronymic;
  51. tempFullName[tempFullName.Length - 1] = userInputFullName;
  52. for (int i = 0; i < fullName.Length; i++)
  53. {
  54. tempFullName[i] = fullName[i];
  55. }
  56. fullName = tempFullName;
  57.  
  58. string[] tempPost = new string[post.Length + 1];
  59. Console.Write("Введите должность: ");
  60. string userInputPost = Console.ReadLine();
  61. tempPost[tempPost.Length - 1] = userInputPost;
  62. for (int i = 0; i < post.Length; i++)
  63. {
  64. tempPost[i] = post[i];
  65. }
  66. post = tempPost;
  67.  
  68. Console.WriteLine("Новое досье: " + userInputFullName + " - " + userInputPost);
  69. Console.Write("Нажмите Enter чтобы вернуться в меню.");
  70. Console.ReadLine();
  71. }
  72. static void ShowDossier(string[] fullName, string[] post)
  73. {
  74. for (int i = 0; i < fullName.Length; i++)
  75. {
  76. Console.WriteLine("Досье сотрудника: №" + (i + 1) + " " + fullName[i] + " - " + post[i]);
  77. }
  78. Console.Write("Нажмите Enter чтобы вернуться в меню.");
  79. Console.ReadLine();
  80. }
  81. static void DeleteDossier(ref string[] fullName, ref string[] post)
  82. {
  83. Console.Write("Введите номер досье: ");
  84. int index = Convert.ToInt32(Console.ReadLine()) - 1;
  85. string[] tempFullName = new string[fullName.Length - 1];
  86. for (int i = 0; i < index; i++)
  87. {
  88. tempFullName[i] = fullName[i];
  89. }
  90. for (int i = index; i < tempFullName.Length; i++)
  91. {
  92. tempFullName[i] = fullName[i + 1];
  93. }
  94. fullName = tempFullName;
  95.  
  96. string[] tempPost = new string[post.Length - 1];
  97. for (int i = 0; i < index; i++)
  98. {
  99. tempPost[i] = post[i];
  100. }
  101. for (int i = index; i < tempPost.Length; i++)
  102. {
  103. tempPost[i] = post[i + 1];
  104. }
  105. post = tempPost;
  106. Console.Write("Нажмите Enter чтобы вернуться в меню.");
  107. Console.ReadLine();
  108. }
  109. static void DossierSearch(ref string[] fullName, ref string[] post, out string userInputFullName)
  110. {
  111. bool employeeFound = false;
  112. Console.Write("Введите ФИО сотрудника через пробел: ");
  113. userInputFullName = Console.ReadLine();
  114. for (int i = 0; i < fullName.Length; i++)
  115. {
  116. if (userInputFullName.ToLower() == fullName[i].ToLower())
  117. {
  118. Console.WriteLine("Досье сотрудника: №" + (i + 1) + " " + fullName[i] + " - " + post[i]);
  119. employeeFound = true;
  120. break;
  121. }
  122. }
  123. if (employeeFound == false)
  124. {
  125. Console.WriteLine("Сотрудника с такой ФИО нету.");
  126. }
  127. Console.Write("Нажмите Enter чтобы вернуться в меню.");
  128. Console.ReadLine();
  129. }
  130. }
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement