Beispiel #1
0
 /// <summary>
 /// Dispaly the animals at each zoo location
 /// </summary>
 public void DisplayZooInfo()
 {
     foreach (var item in ZooInfo.OrderBy(i => i.Key))
     {
         Console.WriteLine($"{item.Key} Zoo has the following animal:");
         for (int i = 0; i < item.Value.Count; i++)
         {
             Animal a = new Animal();
             a.DisplayZooInfo(item.Value[i]);
         }
         Console.WriteLine();
     }
 }
Beispiel #2
0
 /// <summary>
 /// Calculate the average height of the zoo location
 /// </summary>
 public void AverageWeights()
 {
     foreach (var item in ZooInfo.OrderBy(i => i.Key))
     {
         double avg   = 0;
         int    count = 0;
         AverageWeight = 0;
         for (int i = 0; i < item.Value.Count; i++)
         {
             Animal a = new Animal();
             avg            = a.CalculateAverageWeight(item.Value[i]);
             AverageWeight += avg;
             count++;
         }
         AverageWeight = AverageWeight / count;
         Console.WriteLine($"{item.Key} Zoo has an average weight of {AverageWeight.ToString("N2")} pounds.");
         Console.WriteLine();
     }
 }