Пример #1
0
 public Dragon GetLargestofType(string type)
 {
     foreach (Dragon dragon in dignity)
     {
         if (dragon.getType() == type)
         {
             DragonType.Add(dragon);
         }
     }
     if (DragonType.Count == 0)
     {
         Console.WriteLine($"There are no dragons of {type} in the dignity");
         return(null);
     }
     else
     {
         Dragon Largest = new Dragon("", "", 0, true);
         foreach (Dragon dragon in DragonType)
         {
             if (dragon.GetSize() > Largest.GetSize())
             {
                 Largest = dragon;
             }
         }
         return(Largest);
     }
 }
Пример #2
0
        public Dragon GetLargest()
        {
            Dragon largest = new Dragon("", "", 0, true);

            foreach (Dragon dragon in dignity)
            {
                if (dragon.GetSize() > largest.GetSize())
                {
                    largest = dragon;
                }
            }
            return(largest);
        }