static void Main(string[] args) { FruitSalad fruitSalad = new FruitSalad() { _fruits = new Fruit[] { new Apple { _name = "Granny Smith", _color = "Green", _calories = 58, _pinkLady = false }, new Coconut { _name = "Green Coconut", _calories = 36, _waterInIt = 0.5f }, new Pineapple { _name = "Red Spanish Pinapple", _calories = 82, _price = 40 }, new Banana { _name = "Banana", _calories = 30, _size = 14.9f, _IsGreen = true } } }; Apple a = new Apple() { _name = "Granny Smith", _color = "Green", _calories = 58, _pinkLady = false }; Banana b = new Banana { _name = "Banana", _calories = 45, _size = 17.9f, _IsGreen = true }; Console.WriteLine("============Apple Color============="); PrintColor(a); Console.WriteLine("============Banana Size============="); BananaSize(b); Console.WriteLine("============Fruit Salad Calories============="); PrintCalories(fruitSalad); Console.WriteLine("============Fruit Salad Favorite============="); PrintFavorite(fruitSalad); }
static void BananaSize(Banana banana) { Console.WriteLine(banana._size); }