Advertisement
MaoChessy

Task 40

Nov 20th, 2020
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace LinqTrain
  6. {
  7.     class Program
  8.     {
  9.         public static void Main()
  10.         {
  11.             List<Criminal> criminals = new List<Criminal>();
  12.             Console.WriteLine("Список до исключения (Антиправительственное)");
  13.             for (int i = 0; i < 201; i++)
  14.             {
  15.                 criminals.Add(new Criminal());
  16.                 Console.WriteLine($"{i}: {criminals[i].GetInfo()}");
  17.             }
  18.             Console.ReadKey();
  19.  
  20.             var filltedList = criminals.Where(criminal => criminal.CrimeName.ToLower() != "Антиправительственное".ToLower());
  21.             criminals = filltedList.ToList<Criminal>();
  22.  
  23.             Console.Clear();
  24.             Console.WriteLine("Список после исключения (Антиправительственное)");
  25.             for (int i = 0; i < criminals.Count; i++)
  26.             {
  27.                 Console.WriteLine($"{i}: {criminals[i].GetInfo()}");
  28.             }
  29.             Console.ReadKey();
  30.         }
  31.     }
  32.     public static class RandomStatic
  33.     {
  34.         static private Random _rand = new Random();
  35.         static public int GetNext(int min, int max)
  36.         {
  37.             return _rand.Next(min, max);
  38.         }
  39.     }
  40.     class FullName
  41.     {
  42.         public string Name { get; private set; }
  43.         public string Surname { get; private set; }
  44.         public string Patronymic { get; private set; }
  45.         public FullName()
  46.         {
  47.             Name = new string[] { "Август", "Богдан", "Ваня", "Георгий", "Данил", "Женя" }[RandomStatic.GetNext(0, 6)];
  48.             Surname = new string[] { "ЛУчников", "Захарчев", "Зайцев", "КУзнецов", "Столяров", "Коробничиков" }[RandomStatic.GetNext(0, 6)];
  49.             Patronymic = new string[] { "Сергеевич", "Андреевич", "Саавич", "Арсеневич" }[RandomStatic.GetNext(0, 4)];
  50.         }
  51.         public string GetInfo()
  52.         {
  53.             return $"{Surname} {Name} {Patronymic}:";
  54.         }
  55.     }
  56.     class Criminal
  57.     {
  58.         public FullName FullNamee { get; private set; }
  59.         public string CrimeName { get; private set; }
  60.         public Criminal()
  61.         {
  62.             FullNamee = new FullName();
  63.             int index = RandomStatic.GetNext(0, 10);
  64.             if (index > 2)
  65.                 index = 0;
  66.             CrimeName = new string[] { "Антиправительственное", "Убйство", "Корупция" }[index];
  67.         }
  68.         public string GetInfo()
  69.         {
  70.             return $"{FullNamee.GetInfo()} {CrimeName}";
  71.         }
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement