Exemple #1
0
        public static void MainOLD()
        {
            var woodenDoorFactory       = new WoodenDoorFactory();
            var woodenDoor              = woodenDoorFactory.MakeDoor();
            var woodenDoorFactoryExpert = woodenDoorFactory.GetFittingExpert();

            var ironDoorFactory       = new IronDoorFactory();
            var ironDoor              = ironDoorFactory.MakeDoor();
            var ironDoorFactoryExpert = ironDoorFactory.GetFittingExpert();

            woodenDoor.GetDescription();
            woodenDoorFactoryExpert.GetDescription();

            ironDoor.GetDescription();
            ironDoorFactoryExpert.GetDescription();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            WoodenDoorFactory  woodenDoorFactory = new WoodenDoorFactory();
            IDoor              door   = woodenDoorFactory.MakeDoor();
            IDoorFittingExpert expert = woodenDoorFactory.MakeDoorFittingExpert();

            door.GetDescription();
            expert.GetDescription();

            IronDoorFactory    ironDoorFactory = new IronDoorFactory();
            IDoor              door2           = ironDoorFactory.MakeDoor();
            IDoorFittingExpert expert2         = ironDoorFactory.MakeDoorFittingExpert();

            door2.GetDescription();
            expert2.GetDescription();

            Console.ReadKey();
        }
        public static void Run()
        {
            Console.WriteLine("=-=-=-=AbstractFactory=-=-=-=");

            Console.WriteLine("WoodenDoorFactory");
            var woodenFactory = new WoodenDoorFactory();

            var door   = woodenFactory.MakeDoor();
            var expert = woodenFactory.MakeFittingExpert();

            door.GetDescription();   // Output: I am a wooden door
            expert.GetDescription(); // Output: I can only fit wooden doors

            Console.WriteLine(Environment.NewLine + "IronDoorFactory");
            var ironFactory = new IronDoorFactory();

            door   = ironFactory.MakeDoor();
            expert = ironFactory.MakeFittingExpert();

            door.GetDescription();   // Output: I am an iron door
            expert.GetDescription(); // Output: I can only fit iron doors

            Console.WriteLine("----------------------------------" + Environment.NewLine);
        }