コード例 #1
0
        static void Main(string[] args)
        {
            Apple  apple  = new Apple(false, "red");
            Orange orange = new Orange(3.4f);
            Banana banana = new Banana(true, false, 2.5f);
            Grapes grapes = new Grapes(false, "green");

            Fruit[] fruit = new Fruit[4] {
                apple, orange, banana, grapes
            };
            FruitSalad fruitSalad = new FruitSalad(fruit);

            PrintAppleColor(apple);
            printBananaSize(banana);
            PrintCalories(fruitSalad);
            IsMyFavorite(fruitSalad);
            FruitSalad fruitSaladFromFun = createSalad(fruit);

            Console.WriteLine(fruitSalad.ToString());

            Console.ReadLine();
        }
コード例 #2
0
 private static void PrintAppleColor(Apple apple)
 {
     Console.WriteLine($"apple calories: {apple._calories}");
 }