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

            Console.WriteLine(a);
            Banana b = new Banana()
            {
                _name           = "banana",
                _calories       = 88,
                _hasBalackSpots = true,
                _isGreen        = false,
                _size           = 15.3f
            };

            Console.WriteLine(b);
            Pineapple p = new Pineapple()
            {
                _name          = "pineapple",
                _calories      = 50,
                _originCountry = "Costa Rica",
                _weight        = 3.2f
            };

            Console.WriteLine(p);
            Orange o = new Orange()
            {
                _name     = "orange",
                _calories = 47,
                _isSweet  = false,
                _shape    = "round"
            };

            Console.WriteLine(o);


            Fruit[]    fruits      = new Fruit[] { b, p, a };
            Fruitsalad fruitsalad1 = new Fruitsalad()
            {
                _fruits = fruits
            };
        }
Пример #2
0
 static void PrintColor(Apple a)
 {
     Console.WriteLine(a._color);
     Console.WriteLine(a);
 }