public override void ProcessResources() { Resources.ForEach(animal => { IMeatProducing resource = (IMeatProducing)animal; System.Console.WriteLine($"{resource.Butcher()}kg of meat was produced"); }); }
public void ProcessResults(List <IResource> resProcessed) { Dictionary <string, double> meatProduced = new Dictionary <string, double>(); resProcessed.ForEach(animal => { IMeatProducing resource = (IMeatProducing)animal; try { meatProduced.Add(resource.GetType().Name, resource.Butcher()); } catch (Exception) { meatProduced[resource.GetType().Name] += resource.Butcher(); } }); foreach (KeyValuePair <string, double> animal in meatProduced) { System.Console.WriteLine($"{animal.Value}kg of {animal.Key} meat was produced"); } }