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<Prisoner> {
- new Prisoner("ФИО_1", "Антиправительственное"),
- new Prisoner("ФИО_2", "Другое"),
- new Prisoner("ФИО_3", "Антиправительственное"),
- new Prisoner("ФИО_4", "Другое"),
- new Prisoner("ФИО_5", "Антиправительственное"),
- new Prisoner("ФИО_6", "Другое"),
- new Prisoner("ФИО_7", "Другое"),
- new Prisoner("ФИО_8", "Антиправительственное"),
- new Prisoner("ФИО_9", "Антиправительственное"),
- });
- archive.IsUse();
- }
- }
- class Prisoner
- {
- public string Initials { get; private set; }
- public string Сrime { get; private set; }
- public Prisoner(string initials, string сrime)
- {
- Initials = initials;
- Сrime = сrime;
- }
- public void ShowInfo()
- {
- Console.WriteLine($"{Initials} | {Сrime}");
- }
- }
- class Archive
- {
- List<Prisoner> _prisoners;
- public Archive(List<Prisoner> perpetrator)
- {
- _prisoners = perpetrator;
- }
- public void IsUse()
- {
- Console.WriteLine("Список преступников: ");
- ShowPerpetrators();
- _prisoners = _prisoners.Where(prisoner => prisoner.Сrime != "Антиправительственное").ToList();
- Console.WriteLine("Список оставшихся преступников: ");
- ShowPerpetrators();
- Console.ReadKey();
- }
- private void ShowPerpetrators()
- {
- foreach (var prisoner in _prisoners)
- {
- prisoner.ShowInfo();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment