Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ООП
- {
- class Program
- {
- static void Main(string[] args)
- {
- Archive archive = new Archive( new List<Perpetrator> {
- new Perpetrator("Николай Дмитриевич", false, 165, 70, "русский"),
- new Perpetrator("Иван Иванович", false, 175, 75, "русский"),
- new Perpetrator("Дмитрий Владимирович", false, 175, 75, "русский"),
- new Perpetrator("Афанасий Афанасиевич", false, 170, 90, "беларус"),
- new Perpetrator("Армен Арменович", true, 180, 80, "армянин"),
- new Perpetrator("Дмитрий Николаевич", false, 180, 80, "русский"),
- new Perpetrator("Артём Владимирович", true, 175, 80, "беларус"),
- });
- archive.IsUse();
- }
- }
- class Perpetrator
- {
- public string Initials { get; private set; }
- public bool IsLockedUp { get; private set; }
- public int Growth { get; private set; }
- public int Weight { get; private set; }
- public string Ethnicity { get; private set; }
- public Perpetrator(string initials, bool isLockedUp, int growth, int weight, string ethnicity)
- {
- Initials = initials;
- IsLockedUp = isLockedUp;
- Growth = growth;
- Weight = weight;
- Ethnicity = ethnicity;
- }
- public void ShowInfo()
- {
- Console.WriteLine($"{Initials} | Заключён: {IsLockedUp} | Рост: {Growth} | Вес: {Weight} | {Ethnicity}");
- }
- }
- class Archive
- {
- List<Perpetrator> _perpetrators;
- public Archive(List<Perpetrator> perpetrator)
- {
- _perpetrators = perpetrator;
- }
- public void IsUse()
- {
- bool isOpen = true;
- int growth;
- int weight;
- string ethnicity;
- while (isOpen)
- {
- Console.Clear();
- Console.WriteLine("Поиск преступника из архива");
- growth = CorrectInput("рост: ");
- weight = CorrectInput("вес: ");
- Console.Write("Введите национальность: ");
- ethnicity = Console.ReadLine();
- var results = from Perpetrator perpetrator in _perpetrators where perpetrator.IsLockedUp == false where perpetrator.Growth == growth where perpetrator.Weight == weight where perpetrator.Ethnicity == ethnicity select perpetrator;
- Console.WriteLine("Список найденых преступников: ");
- foreach (var result in results)
- {
- result.ShowInfo();
- }
- Console.ReadKey();
- }
- }
- private int CorrectInput(string label)
- {
- bool correctImput = false;
- int correctNumber = 0;
- while (correctImput == false)
- {
- Console.Write($"Введите {label}");
- string userInput = Console.ReadLine();
- correctImput = int.TryParse(userInput, out correctNumber);
- }
- return correctNumber;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement