Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Амнистия
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- DataBase dataBase = new DataBase();
- dataBase.Work();
- }
- }
- class DataBase
- {
- private List<Criminal> _criminals = new List<Criminal>();
- public DataBase()
- {
- _criminals.Add(new Criminal("Разбой", "Иван", "Иванов"));
- _criminals.Add(new Criminal("Кража", "Сергей", "Сергеев"));
- _criminals.Add(new Criminal("Антиправительственное", "Петр", "Петров"));
- _criminals.Add(new Criminal("Убийство", "Антон", "Антонов"));
- _criminals.Add(new Criminal("Антиправительственное", "Кирилл", "Кириллов"));
- }
- public void Work()
- {
- Console.ForegroundColor = ConsoleColor.DarkYellow;
- Console.WriteLine("Список преступников до амнистии:");
- Console.ForegroundColor = ConsoleColor.White;
- ShowCriminalsList();
- Console.ForegroundColor = ConsoleColor.DarkYellow;
- Console.WriteLine("\nСписок преступников после амнистии:");
- Console.ForegroundColor = ConsoleColor.White;
- Amnesty();
- ShowCriminalsList();
- }
- private void Amnesty()
- {
- _criminals = _criminals.Where(criminal => criminal.Crime != "Антиправительственное").ToList();
- }
- private void ShowCriminalsList()
- {
- foreach (var criminal in _criminals)
- {
- criminal.ShowDescription();
- }
- }
- }
- class Criminal
- {
- private string _name;
- private string _surName;
- public Criminal(string crime, string name, string surname)
- {
- _name = name;
- _surName = surname;
- Crime = crime;
- }
- public string Crime { get; private set; }
- public void ShowDescription()
- {
- Console.WriteLine($"Имя: {_name} Фамилия: {_surName} Преступление: {Crime}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement