Beispiel #1
0
        static FruitSalad FruitsArray(Fruit[] fruits_array)
        {
            FruitSalad fruitSalad = new FruitSalad()
            {
                _fruits = fruits_array
            };

            return(fruitSalad);
        }
Beispiel #2
0
 static void PrintFavorite(FruitSalad fav)
 {
     for (int i = 0; i < fav._fruits.Length; i++)
     {
         if (fav.ContainsMyFavoriteFruit())
         {
             Console.WriteLine(fav._fruits[i]);
         }
     }
 }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 static void PrintCalories(FruitSalad saladCalories)
 {
     Console.WriteLine(saladCalories.GetToatalCalories());
 }