Exemplo n.º 1
0
        void start()
        {
            Console.WriteLine("[shop creating actual good computers]");
            ComputerShop highEndComputerShop = new ComputerShop(new HighBudgetFactory());

            highEndComputerShop.buildComputer();
            highEndComputerShop.runComputer();

            Console.WriteLine();
            Console.WriteLine("[shop creating crappy computers]");
            ComputerShop crappyComputerShop = new ComputerShop(new LowBudgetFactory());

            crappyComputerShop.buildComputer();
            crappyComputerShop.runComputer();

            Console.ReadKey();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // create a shop where they assemble expensive computers
            Console.WriteLine("[shop creating expensive computers]");
            IMachineFactory factory1 = new HighBudgetMachine();
            ComputerShop    shop1    = new ComputerShop(factory1);

            shop1.AssembleMachine();
            Console.WriteLine();

            // create a shop where they assemble cheap computers
            Console.WriteLine("[shop creating cheap computers]");
            IMachineFactory factory2 = new LowBudgetMachine();
            ComputerShop    shop2    = new ComputerShop(factory2);

            shop2.AssembleMachine();
            Console.ReadKey();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            //Er is toch maar één shop nodig?
            ComputerShop shop = new ComputerShop();

            Console.WriteLine("[shop creating cheap computers]");
            ComputerFactory lowBudgetComputerFactory = new LowBudgetFactory();

            shop.CreateComputer(lowBudgetComputerFactory);

            Console.WriteLine();

            Console.WriteLine("[shop creating expensive computers]");
            ComputerFactory highBudgetComputerFactory = new HighBudgetFactory();

            shop.CreateComputer(highBudgetComputerFactory);

            Console.ReadKey();
        }
Exemplo n.º 4
0
        private void Start()
        {
            //A single shop is created because it can use different factory's
            ComputerShop shop = new ComputerShop();

            // create a shop where they assemble expensive computers
            Console.WriteLine("[shop creating expensive computers]");
            ComputerFactory expensiveFactory = new HighBudgetFactory();

            shop.CreateComputer(expensiveFactory);

            Console.WriteLine();

            // create a shop where they assemble cheap computers
            Console.WriteLine("[shop creating cheap computers]");
            ComputerFactory cheapFactory = new LowBudgetFactory();

            shop.CreateComputer(cheapFactory);
        }