コード例 #1
0
ファイル: Program.cs プロジェクト: anniexp/ZooparkDP
        /// <summary>
        /// Printing in console each implementation of the IAnimal
        /// </summary>
        /// <param name="animal"></param>
        public static void ListAnimal(IAnimal animal)
        {
            Console.WriteLine("\n---------------------------");
            Console.WriteLine("Animal kind: {0}", animal.AnimalKind());

            Console.WriteLine(" Type of animal by biology : {0}", animal.TypeOfAnimal());

            Console.WriteLine(" Region : {0}", animal.Region());

            Console.WriteLine(" Type of animal by what they eat: {0}", animal.TypeOfAnimalByWhatTheyEat());

            Console.WriteLine(" Description : {0}", animal.Description());

            Console.WriteLine(" Quantity : {0}", animal.Quantity());

            // asiigning type of cage (big/small) depending of type of animal(mammal, bird or reptile)
            if (animal.TypeOfAnimal() == "bird")
            {
                //Abstraction obj = new RefinedAbstraction();
                Bridge.Type type = new SmallCage();
                // Set implementation and call
                type._ICage = new Bird();
                type.MakeType();
            }
            else if (animal.TypeOfAnimal() == "reptile")
            {
                Bridge.Type type = new SmallCage();
                type._ICage = new Reptile();
                type.MakeType();
            }
            else if (animal.TypeOfAnimal() == "mammal")
            {
                // Change implemention and call
                Bridge.Type type = new BigCage();
                type._ICage = new Mammal();
                type.MakeType();
            }
        }