Advertisement
LeRoY_Go

Untitled

Jun 14th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.12 KB | None | 0 0
  1. using 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. SearchDossier(fullName, post, userInputFullName);
  32. break;
  33. case "5":
  34. Environment.Exit(50);
  35. break;
  36.  
  37. }
  38. Console.Write("Нажмите Enter чтобы вернуться в меню.");
  39. Console.ReadLine();
  40. Console.Clear();
  41. }
  42. }
  43. static void AddDossier(ref string[] fullName, ref string[] post, out string userInputFullName)
  44. {
  45. string[] tempFullName = new string[fullName.Length + 1];
  46. string[] tempPost = new string[post.Length + 1];
  47. Console.Write("Ввидите фомилию: ");
  48. string userInputSurname = Console.ReadLine();
  49. Console.Write("Ввидите имя: ");
  50. string userInputName = Console.ReadLine();
  51. Console.Write("Ввидите отчество: ");
  52. string userInputPatronymic = Console.ReadLine();
  53. userInputFullName = userInputSurname + " " + userInputName + " " + userInputPatronymic;
  54. tempFullName[tempFullName.Length - 1] = userInputFullName;
  55.  
  56. Console.Write("Ввидите должность: ");
  57. string userInputPost = Console.ReadLine();
  58. tempPost[tempPost.Length - 1] = userInputPost;
  59. for (int i = 0; i < fullName.Length; i++)
  60. {
  61. tempFullName[i] = fullName[i];
  62. tempPost[i] = post[i];
  63. }
  64. fullName = tempFullName;
  65. post = tempPost;
  66. Console.WriteLine("Новое досье: " + userInputFullName + " - " + userInputPost);
  67. }
  68. static void ShowDossier(string[] fullName, string[] post)
  69. {
  70. for (int i = 0; i < fullName.Length; i++)
  71. {
  72. Console.WriteLine("Досье сотрудника: №" + (i + 1) + " " + fullName[i] + " - " + post[i]);
  73. }
  74. }
  75. static void DeleteDossier(ref string[] fullName, ref string[] post)
  76. {
  77. Console.Write("Ввидите номер досье: ");
  78. int index = Convert.ToInt32(Console.ReadLine()) - 1;
  79. string[] tempFullName = new string[fullName.Length - 1];
  80. string[] tempPost = new string[post.Length - 1];
  81. for (int i = 0; i < index; i++)
  82. {
  83. tempFullName[i] = fullName[i];
  84. tempPost[i] = post[i];
  85. }
  86. for (int i = index; i < tempFullName.Length; i++)
  87. {
  88. tempFullName[i] = fullName[i + 1];
  89. tempPost[i] = post[i + 1];
  90. }
  91. fullName = tempFullName;
  92. post = tempPost;
  93. }
  94. static void SearchDossier(string[] fullName, string[] post, string userInputFullName)
  95. {
  96. bool employeeFound = false;
  97. Console.Write("Введите ФИО сотрудника через пробел: ");
  98. userInputFullName = Console.ReadLine();
  99. for (int i = 0; i < fullName.Length; i++)
  100. {
  101. if (userInputFullName.ToLower() == fullName[i].ToLower())
  102. {
  103. Console.WriteLine("Досье сотрудника: №" + (i + 1) + " " + fullName[i] + " - " + post[i]);
  104. employeeFound = true;
  105. break;
  106. }
  107. }
  108. if (employeeFound == false)
  109. {
  110. Console.WriteLine("Сотрудника с токой ФИО нету.");
  111. }
  112. }
  113. }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement