static void Main(string[] args) { Student student1 = new Student(1, "Studen1Name", "Student2Surname"); Student studentCopy = new Student(1, "Studen1Name", "Student2Surname"); Pensioner pensioner1 = new Pensioner(2, "Pensioner1Name", "Pensioner1Surname"); Worker worker1 = new Worker(3, "Worker1Name", "Worker2Surname"); Pensioner pensioner2 = new Pensioner(4, "Pensioner2Name", "Pensioner2Surname"); CitizenCollection collection = new CitizenCollection(); collection.Add(student1); //collection.Add(studentCopy); collection.Add(pensioner1); collection.Add(worker1); collection.Add(pensioner2); foreach (Citizen item in collection) { System.Console.WriteLine($"{item.Id} {item.Name}"); } System.Console.WriteLine(); collection.Remove(pensioner1); foreach (Citizen item in collection) { System.Console.WriteLine($"{item.Id} {item.Name}"); } System.Console.WriteLine(); collection.Remove(worker1); foreach (Citizen item in collection) { System.Console.WriteLine($"{item.Id} {item.Name}"); } }
static void Main(string[] args) { CitizenCollection persons = new CitizenCollection(); Pensioner pensioner = new Pensioner("p3", "p3"); persons.Add(new Student("s1", "s1")); persons.Add(new Worker("w1", "w1")); persons.Add(new Pensioner("p1", "p1")); LogPersons(persons); persons.Add(new Student("s2", "s2")); persons.Add(new Worker("w2", "w2")); persons.Add(new Pensioner("p2", "p2")); LogPersons(persons); persons.Add(new Pensioner("p2", "p2")); persons.Add(pensioner); LogPersons(persons); persons.Remove(); LogPersons(persons); persons.Remove(pensioner); LogPersons(persons); }
private void AddCitizen(Citizen citizen) { citiPopulation.Add(citizen); }