Пример #1
0
        static void Main(string[] args)
        {
            Apple pinkLadyApple = new Apple()
            {
                _color    = "red",
                _pinkLady = true,
                _name     = "pinkLadyApple",
                _calories = 10,
            };

            PrintApple(pinkLadyApple);

            Banana FreshBanana = new Banana()
            {
                _hasBlackSpots = false,
                _isGreen       = true,
                _size          = 7,
                _name          = "FreshBanana",
                _calories      = 30,
            };

            PrintBanana(FreshBanana);

            Orange citrusOrange = new Orange()
            {
                _name     = "citrusOrange",
                _calories = 50,
                _citrus   = true,
            };
            Strawberry wildStrawberry = new Strawberry()
            {
                _name     = "wildStrawberry",
                _calories = 20,
                _amount   = 2,
            };


            FruitSalad salad = new FruitSalad()
            {
                _fruit = new FruitBase[]
                {
                    pinkLadyApple,
                    FreshBanana,
                    citrusOrange,
                    wildStrawberry
                }
            };


            FruitBase[] my_fruit_array = new FruitBase[]
            {
                pinkLadyApple,
                FreshBanana,
                citrusOrange,
                wildStrawberry
            };
            FruitSalad salad2 = new FruitSalad()
            {
                _fruit = my_fruit_array
            };

            PrintCalories(salad);

            PrintFavorite(salad);
        }
Пример #2
0
 static void PrintApple(Apple pinkLadyApple)
 {
     Console.WriteLine($"The Color Is {pinkLadyApple._color}");
 }