예제 #1
0
        static void Main(string[] args)
        {
            try
            {
                IFactory factory = new CatFactory();
                IAnimal  animal  = factory.CreateInstance();
                animal.Declare();

                factory = new HumanFactory();
                animal  = factory.CreateInstance();
                animal.Declare();
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("----- Factory Method Pattern Implementation -----");
            Console.WriteLine("");

            IAnimalFactory FactoryDog = new DogFactory();
            IAnimal        animal     = FactoryDog.MakeAnimal();

            //animal.Speak();
            //animal.Action();

            Console.WriteLine("");
            IAnimalFactory FactoryCat = new CatFactory();

            animal = FactoryCat.MakeAnimal();
            //animal.Speak();
            //animal.Action();

            Console.Read();
        }