Advertisement
Guest User

Untitled

a guest
May 26th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.44 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp3
  8. {
  9.     class MainClass
  10.     {
  11.         public static void Main(string[] args)
  12.         {
  13.             string[] appointment = new string[0];
  14.             string[] fio = new string[0];
  15.             int list;
  16.             string menu;
  17.             bool work = true;
  18.             while (true)
  19.             {
  20.  
  21.                 Console.WriteLine("Список доступных команд: \nNew - добавить новое досье. \nList - вывести список досье. \nDel - удалить досье. \nEsc - выход.");
  22.                 Console.Write("Введите команду: ");
  23.                 menu = Console.ReadLine().ToLower();
  24.                 if (menu == "new")
  25.                 {
  26.                     New(ref fio, ref appointment);
  27.                     continue;
  28.                 }
  29.                 else if (menu == "list")
  30.                 {
  31.                     Console.Clear();
  32.                     for (int i = 0; i < fio.Length; i++)
  33.                     {
  34.                         Console.WriteLine(i + 1 + ". " + fio[i] + " - " + appointment[i]);
  35.                     }
  36.                     Console.WriteLine("Нажмите любую клавишу, чтобы вернуться в меню.");
  37.                     Console.ReadKey();
  38.                     Console.Clear();
  39.                     continue;
  40.                 }
  41.                 else if (menu == "del")
  42.                 {
  43.                     Delete(ref fio, ref appointment);
  44.                     continue;
  45.                 }
  46.                 else if (menu == "esc")
  47.                 {
  48.                     work = false;
  49.                     continue;
  50.                 }
  51.                 else
  52.                 {
  53.                     Console.Clear();
  54.                     Console.WriteLine("Я не знаю такой комманды!");
  55.                     Console.WriteLine();
  56.                     continue;
  57.                 }
  58.             }
  59.  
  60.         }
  61.         public static void New(ref string[] fio, ref string[] appointment)
  62.         {
  63.             Console.WriteLine("Введите имя, фамилию и отчество нового сотрудника: ");
  64.             string menu = Console.ReadLine();
  65.             string[] tempfio = new string[fio.Length + 1];
  66.             for (int i = 0; i < fio.Length; i++)
  67.             {
  68.                 tempfio[i] = fio[i];
  69.             }
  70.             tempfio[fio.Length] = menu;
  71.             fio = tempfio;
  72.  
  73.             Console.WriteLine("Введите должность нового сотрудника: ");
  74.             menu = Console.ReadLine();
  75.             string[] tempappointment = new string[appointment.Length + 1];
  76.             for (int i = 0; i < appointment.Length; i++)
  77.             {
  78.                 tempfio[i] = appointment[i];
  79.             }
  80.             tempfio[appointment.Length] = menu;
  81.             appointment = tempfio;
  82.             Console.Clear();
  83.             Console.WriteLine("Данные сохранены!");
  84.             Console.WriteLine();
  85.         }
  86.         public static void Delete(ref string[] fio, ref string[] appointment)
  87.         {
  88.             Console.Clear();
  89.             for (int i = 0; i < fio.Length; i++)
  90.             {
  91.                 Console.WriteLine(i + 1 + ". " + fio[i] + " - " + appointment[i]);
  92.             }
  93.             Console.Write("Введите номер удаляемого досье: ");
  94.             int list = Convert.ToInt32(Console.ReadLine());
  95.             if (list <= fio.Length && list >= 1)
  96.             {
  97.                 Console.WriteLine("Вы действительно хотиту удалить досье сотрудника\n" + fio[list - 1] + " - " + appointment[list - 1] + "?\nНажимте Y для подтверждения или N для отмены");
  98.                 string menu = Console.ReadLine().ToLower();
  99.                 if (menu == "n")
  100.                 {
  101.                  
  102.                 }
  103.                 else if (menu == "y")
  104.                 {
  105.                     for (int i = list - 1; i < fio.Length - 1; i++)
  106.                     {
  107.                         fio[i] = fio[i + 1];
  108.                         appointment[i] = appointment[i + 1];
  109.                     }
  110.                     string[] tempfio = new string[fio.Length - 1];
  111.                     string[] tempappointment = new string[appointment.Length - 1];
  112.                     for (int i = 0; i < tempfio.Length; i++)
  113.                     {
  114.                         tempfio[i] = fio[i];
  115.                         tempfio[i] = appointment[i];
  116.                     }
  117.                     fio = tempfio;
  118.                     appointment = tempfio;
  119.                     Console.WriteLine("Выбранное досье удалено");
  120.                 }
  121.                 else
  122.                 {
  123.                     Console.WriteLine("Что-то пошло не так.");
  124.                 }
  125.                 Console.WriteLine("Для продолжения нажмите любую колавишу.");
  126.                 Console.ReadKey();
  127.                 Console.Clear();
  128.             }
  129.             else
  130.             {
  131.               Console.Clear();
  132.               Console.WriteLine("Что-то пошло не так. Возможно такого досье нет в базе.");
  133.               Console.WriteLine();
  134.             }
  135.  
  136.  
  137.         }
  138.     }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement