Exemplo n.º 1
0
            public override void ApplyOperation(Animals[] A, AnimalsProperty AP)
            {
                switch (AP)
                {
                case AnimalsProperty.PrintNames:
                    foreach (var item in A)
                    {
                        Console.Write($" {item.Name},");
                    }
                    break;

                case AnimalsProperty.MAXBodyLength:
                    float max = A[0].BodyLength;
                    for (int i = 0; i < A.Length; i++)
                    {
                        if (max < A[i].BodyLength)
                        {
                            max = A[i].BodyLength;
                        }
                    }
                    Console.WriteLine($"Максимальная длина тела: {max}");
                    break;

                case AnimalsProperty.TotalWeight:
                    double count = 0;
                    foreach (var item in A)
                    {
                        count += item.Weight;
                    }
                    Console.WriteLine($"Общий вес животных равен: {count}");
                    break;
                }
            }
Exemplo n.º 2
0
 public abstract void ApplyOperation(Animals[] A, AnimalsProperty AP);