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()
- {
- bool isOpen = true;
- while (isOpen)
- {
- List<Criminal> criminals = new List<Criminal>();
- for (int i = 0; i < 80; i++)
- {
- criminals.Add(new Criminal());
- Console.WriteLine($"{i}: {criminals[i].GetInfo()}");
- }
- Console.ReadKey(true);
- Console.Clear();
- int height, weight;
- string nationality;
- Console.Write("Введите минимальный рост: ");
- height = Convert.ToInt32(Console.ReadLine());
- Console.Write("Введите минимальный вес: ");
- weight = Convert.ToInt32(Console.ReadLine());
- Console.Write("Введите Национальность: ");
- nationality = Console.ReadLine();
- var filltedList = from Criminal crim in criminals
- where crim.Height >= height
- where crim.Weight >= weight
- where crim.Nationality.ToLower() == nationality.ToLower()
- where crim.IsJail == false
- select crim;
- Console.Clear();
- int count = 0;
- foreach (var item in filltedList)
- {
- Console.WriteLine($"{count}: {item.GetInfo()}");
- count++;
- }
- if (Console.ReadKey().Key == ConsoleKey.Escape)
- isOpen = false;
- }
- }
- }
- 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 MiddleName { get; private set; }
- public FullName()
- {
- Name = new string[] { "Август", "Богдан", "Ваня", "Георгий", "Данил", "Женя" }[RandomStatic.GetNext(0, 6)];
- Surname = new string[] { "ЛУчников", "Захарчев", "Зайцев", "КУзнецов", "Столяров", "Коробничиков" }[RandomStatic.GetNext(0, 6)];
- MiddleName = new string[] { "Сергеевич", "Андреевич", "Саавич", "Арсеневич" }[RandomStatic.GetNext(0, 4)];
- }
- }
- class Criminal
- {
- public FullName FullName { get; private set; }
- public string Nationality { get; private set; }
- public int Height { get; private set; }
- public int Weight { get; private set; }
- public bool IsJail { get; private set; }
- public Criminal()
- {
- FullName = new FullName();
- IsJail = Convert.ToBoolean(RandomStatic.GetNext(0, 2));
- Height = RandomStatic.GetNext(140, 200);
- Weight = RandomStatic.GetNext(40, 120);
- Nationality = new string[] { "Бразилец", "Канадец", "Мексиканец", "Португалец", "Француз" }[RandomStatic.GetNext(0, 5)];
- }
- public string GetInfo()
- {
- return $"{FullName.Surname} {FullName.Name} {FullName.MiddleName}- {Nationality}. Рост - {Height}. Вес - {Weight}. Заключен - {IsJail}";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement