Пример #1
0
        private static void AbstractFactory()
        {
            var appleFactory   = new AppleFactory();
            var samsungFactory = new SamsungFactory();

            Console.WriteLine($"Apple Factory phone :{appleFactory.CreatePhone()}");
            Console.WriteLine($"Apple Factory tablet :{appleFactory.CreateTablet()}");
            Console.WriteLine($"Samsung Factory phone :{samsungFactory.CreatePhone()}");
            Console.WriteLine($"Samsung Factory tablet:{samsungFactory.CreateTablet()}");
        }
        public static void Run()
        {
            Console.WriteLine("\tAbstractFactory\t");

            var appleFactory = new AppleFactory();

            var purchaser = new Purchaser(appleFactory);

            purchaser.Buy();


            var sumsungFactory = new SamsungFactory();

            purchaser = new Purchaser(sumsungFactory);
            purchaser.Buy();
        }