Skip to content

Instantly share code, notes, and snippets.

@Strelok78
Last active May 17, 2023 08:08
Show Gist options
  • Save Strelok78/08855b769f8890fa7e39f53bd68d30ff to your computer and use it in GitHub Desktop.
Save Strelok78/08855b769f8890fa7e39f53bd68d30ff to your computer and use it in GitHub Desktop.
There has been an amnesty in our great country of Arstock! All people imprisoned for the crime of "Anti-Government" should be excluded from the list of prisoners.
internal class Program
{
public static void Main()
{
PoliceProgrammUI application = new PoliceProgrammUI();
application.StartUI();
}
}
class PoliceProgrammUI
{
private List<Criminal> _criminals = new List<Criminal>
{
new Criminal("Gadget", "Antigovernment"),
new Criminal("Lelouch vi Britannia", "Antigovernment"),
new Criminal("Roronoa Zoro", "Antigovernment"),
new Criminal("Naruto Uzumaki", "Thief"),
new Criminal("Ronaldinho", "Antigovernment"),
new Criminal("Ronaldo", "Antigovernment"),
new Criminal("Piter Parker", "Killer"),
new Criminal("Hercule Poirot", "Fraud"),
new Criminal("Vincenzo", "Killer")
};
public void StartUI()
{
string amnestyProsecution = "Antigovernment";
Console.WriteLine("In our Great country of Arstotzk Amnesty of Antigovernmental prosecution announced!\n");
ShowCriminals(_criminals);
Console.WriteLine();
MakeAmnesty(amnestyProsecution);
_criminals = _criminals.OrderBy(c => c.Prosecution).ToList();
ShowCriminals(_criminals);
Environment.Exit(0);
}
private void ShowCriminals(List<Criminal> criminals)
{
int counter = 0;
foreach (Criminal criminal in criminals)
{
counter++;
Console.Write($"{counter}. ");
criminal.ShowInfo();
}
}
private void MakeAmnesty(string prosecution)
{
Console.WriteLine($"Amnestyied prosecution: {prosecution}\n");
_criminals = _criminals.Where(criminal => criminal.Prosecution != prosecution).ToList();
}
}
class Criminal
{
public Criminal(string name, string prosecution)
{
Name = name;
Prosecution = prosecution;
}
public string Name { get; private set; }
public string Prosecution { get; private set; }
public void ShowInfo()
{
Console.WriteLine($"Name: {Name}, Prosecution: {Prosecution}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment