illiden

Amnistia

Jul 9th, 2020
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.81 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace Lesson1
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<Prisoner> prisoners = new List<Prisoner>()
  12.             {
  13.                 new Prisoner("Кодол", CrimeType.EspecialyGrave),
  14.                 new Prisoner("Регис", CrimeType.Antigovernment),
  15.                 new Prisoner("Малек", CrimeType.Grave),
  16.                 new Prisoner("Ракша", CrimeType.Grave),
  17.                 new Prisoner("Долл", CrimeType.Antigovernment),
  18.                 new Prisoner("Менрир", CrimeType.Antigovernment),
  19.                 new Prisoner("Толкан", CrimeType.EspecialyGrave),
  20.                 new Prisoner("Хизенгар", CrimeType.Grave),
  21.                 new Prisoner("Леонар", CrimeType.Antigovernment),
  22.             };
  23.  
  24.             Console.WriteLine("Список заключенных до амнистии: ");
  25.             foreach (var prisoner in prisoners)
  26.             {
  27.                 Console.WriteLine(prisoner.Name);
  28.             }
  29.  
  30.             var filtredPprisoners = prisoners.Where(prisoner => prisoner.Crime != CrimeType.Antigovernment);
  31.  
  32.             Console.WriteLine("\nСписок заключенных после амнистии: ");
  33.             foreach (var prisoner in filtredPprisoners)
  34.             {
  35.                 Console.WriteLine(prisoner.Name);
  36.             }
  37.  
  38.             Console.ReadKey();
  39.         }
  40.     }
  41.  
  42.     class Prisoner
  43.     {
  44.         public string Name;
  45.         public CrimeType Crime;
  46.  
  47.         public Prisoner(string name, CrimeType crime)
  48.         {
  49.             Name = name;
  50.             Crime = crime;
  51.         }
  52.     }
  53.  
  54.     enum CrimeType
  55.     {
  56.         Antigovernment,
  57.         EspecialyGrave,
  58.         Grave
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment