Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace LinqTrain
- {
- class Program
- {
- public static void Main()
- {
- List<Criminal> criminals = new List<Criminal>();
- Console.WriteLine("Список до исключения (Антиправительственное)");
- for (int i = 0; i < 201; i++)
- {
- criminals.Add(new Criminal());
- Console.WriteLine($"{i}: {criminals[i].GetInfo()}");
- }
- Console.ReadKey();
- var filltedList = criminals.Where(criminal => criminal.CrimeName.ToLower() != "Антиправительственное".ToLower());
- criminals = filltedList.ToList<Criminal>();
- Console.Clear();
- Console.WriteLine("Список после исключения (Антиправительственное)");
- for (int i = 0; i < criminals.Count; i++)
- {
- Console.WriteLine($"{i}: {criminals[i].GetInfo()}");
- }
- Console.ReadKey();
- }
- }
- public static class RandomStatic
- {
- static private Random _rand = new Random();
- static public int GetNext(int min, int max)
- {
- return _rand.Next(min, max);
- }
- }
- class FullName
- {
- public string Name { get; private set; }
- public string Surname { get; private set; }
- public string Patronymic { get; private set; }
- public FullName()
- {
- Name = new string[] { "Август", "Богдан", "Ваня", "Георгий", "Данил", "Женя" }[RandomStatic.GetNext(0, 6)];
- Surname = new string[] { "ЛУчников", "Захарчев", "Зайцев", "КУзнецов", "Столяров", "Коробничиков" }[RandomStatic.GetNext(0, 6)];
- Patronymic = new string[] { "Сергеевич", "Андреевич", "Саавич", "Арсеневич" }[RandomStatic.GetNext(0, 4)];
- }
- public string GetInfo()
- {
- return $"{Surname} {Name} {Patronymic}:";
- }
- }
- class Criminal
- {
- public FullName FullNamee { get; private set; }
- public string CrimeName { get; private set; }
- public Criminal()
- {
- FullNamee = new FullName();
- int index = RandomStatic.GetNext(0, 10);
- if (index > 2)
- index = 0;
- CrimeName = new string[] { "Антиправительственное", "Убйство", "Корупция" }[index];
- }
- public string GetInfo()
- {
- return $"{FullNamee.GetInfo()} {CrimeName}";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement