Пример #1
0
        static void PrintCalories(FruitSalad fruitSalad)
        {
            int totalCalories = 0;

            for (int i = 0; i < fruitSalad.fruits.Length; i++)
            {
                totalCalories += fruitSalad.fruits[i]._calories;
            }

            Console.WriteLine(totalCalories);
        }
Пример #2
0
        static void Main(string[] args)
        {
            FruitSalad firstSalad = new FruitSalad
            {
                fruits = new Fruit[]
                {
                    new Apple
                    {
                        _calories = 50,
                    },
                    new Mango
                    {
                        _calories = 80,
                    },
                    new Grape
                    {
                        _calories = 65
                    },
                    new Banana
                    {
                        _calories = 25,
                    }
                }
            };

            Apple apple = new Apple
            {
                color = "red"
            };

            PrintAppleColor(apple);

            Banana banana = new Banana
            {
                size = 15.2f
            };

            PrintBananaSize(banana);

            PrintCalories(firstSalad);

            PrintFavorite(firstSalad);
        }
Пример #3
0
 static void PrintFavorite(FruitSalad fruitSalad)
 {
     Console.WriteLine(fruitSalad.ContainsMyFavoriteFruit());
 }