//TEST 4 public void ReleaseAllAnimals() { //Console.WriteLine("There are still animals in the farm, farm is not free"); // Exercised asked to "simply clear the collection", // hence looping though the animals to say that they have left the farm // then clearing the Queue (No dequeuing) foreach (var animal in Animals) { var animalType = animal.GetType().Name; Console.WriteLine($"{animalType} has left the farm"); } // Exercised asked to "simply clear the collection" Animals.Clear(); //if FarmEmptied is not null then call delegate FarmEmpty?.Invoke(); }
// function to execute any event subscription protected void OnFarmEmpty(EventArgs e) { // notify the subscriber FarmEmpty?.Invoke(this, e); }