Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Threading;
- using System.Linq;
- namespace ConsoleApp2
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<Person> criminals = new List<Person>
- {
- new Person("Игорь","Табуретка","Александрович",true),
- new Person("Алексей","Коволенко","Николаевич",false),
- new Person("Наталия","Яюниор","Романовна",false),
- new Person("Виктория","Бондарь","Олеговна",true)
- };
- foreach (var criminal in criminals)
- {
- criminal.ShowInfo();
- }
- Console.WriteLine("Введите рост подозреваемого: ");
- int height;
- int weight;
- string userInputHeight = Console.ReadLine();
- Console.WriteLine("Введите вес подозреваемого: ");
- string userInputWeight = Console.ReadLine();
- Console.WriteLine("Введите национальность подозреваемого: ");
- string userInputNationality = Console.ReadLine();
- if (int.TryParse(userInputHeight, out height) && int.TryParse(userInputWeight, out weight))
- {
- var suspects = criminals.Where(suspect => suspect.Height == height && suspect.Prisoner != true && suspect.Weight == weight && suspect.Nationality == userInputNationality);
- Console.Clear();
- Console.WriteLine("Подозреваемые: ");
- foreach (var suspect in suspects)
- {
- suspect.ShowInfo();
- }
- }
- }
- }
- class Person
- {
- private string _name;
- private string _secondName;
- private string _patronymic;
- public bool Prisoner { get; private set; }
- public int Weight { get; private set; }
- public int Height { get; private set; }
- public string Nationality { get; private set; }
- public Person(string name, string secondName, string patronymic, bool prisoner)
- {
- Random random = new Random();
- List<string> nationalities = new List<string> { "Бурят","Армян","Поляк","Русский"};
- _name = name;
- _secondName = secondName;
- _patronymic = patronymic;
- Prisoner = prisoner;
- Weight = random.Next(50, 90);
- Height = random.Next(160,200);
- Nationality = nationalities[random.Next(0,nationalities.Count)];
- }
- public void ShowInfo()
- {
- Console.WriteLine($"Имя: {_name} || Фамилия: {_secondName} || Отчество: {_patronymic}\nРост: {Height} см || Вес: {Weight} кг || Национальность {Nationality}\n Заключенный: {Prisoner}\n\n");
- }
- }
- }
Add Comment
Please, Sign In to add comment