Esempio n. 1
0
        static void Main(string[] args)
        {
            // Abstract factory #1
            AbstractFactory factory1 = new ConcreteFactory1();
            Client          client1  = new Client(factory1);

            client1.Run();

            // Abstract factory #2
            AbstractFactory factory2 = new ConcreteFactory2();
            Client          client2  = new Client(factory2);

            client2.Run();


            IKFCFactory factory = new CheapPackageFactory();
            KFCFood     food    = factory.CreateFood();

            food.Display();

            KFCDrink drink = factory.CreateDrink();

            drink.Display();

            // Wait for user input
            Console.ReadKey();
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            // interact products on platform 1
            AbstractFactory factory1 = new ConcreteFactory1();
            Client          client1  = new Client(factory1);

            client1.Interact();

            // interact products on platform 2
            AbstractFactory factory2 = new ConcreteFactory2();
            Client          client2  = new Client(factory2);

            client2.Interact();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            AbstractFactory factory  = new ConcreteFactory1();
            AbstractFactory factory2 = new ConcreteFactory2();

            AbstractProductA productA = factory.CreateProductA();

            productA.Action();
            AbstractProductB productB = factory.CreateProductB();

            productB.Execute();

            productA = factory2.CreateProductA();
            productA.Action();
            productB = factory2.CreateProductB();
            productB.Execute();
        }
Esempio n. 4
0
        public static void Main(string[] args)
        {
            // Abstract factory #1
            AbstractFactory factory1 = new ConcreteFactory1();
            Client          client1  = new Client(factory1);

            client1.Run();

            // Abstract factory #2
            AbstractFactory factory2 = new ConcreteFactory2();
            Client          client2  = new Client(factory2);

            client2.Run();

            // Wait for user input
            Console.ReadKey();
        }