Example #1
0
        protected override Pizza CreatePizza(string type)
        {
            Pizza pizza = null;
            IIngredientFactory ingredientFactory = new TaiwanIngredientFactory();

            if (type == "Cheese")
            {
                pizza = new CheesePizza(ingredientFactory);
            }
            else if (type == "Clam")
            {
                pizza = new ClamPizza(ingredientFactory);
            }
            else if (type == "Suede")
            {
                pizza = new ShoePizza(ingredientFactory);
            }
            return(pizza);
        }
Example #2
0
        public override Pizza createPizza(PizzaType type)
        {
            Pizza pizza = null;
            PizzaIngredientFactory ingredientFactory = new NY_PizzaIngredientFactory();

            switch (type)
            {
            case PizzaType.pizza1:
                pizza = new CheesePizza(ingredientFactory);
                break;

            case PizzaType.pizza2:
                // pizza = new NY_Pizza2();
                pizza = new ClamPizza(ingredientFactory);
                break;

            case PizzaType.pizza3:
                // pizza = new NY_Pizza3();
                break;
            }
            return(pizza);
        }
Example #3
0
        protected override Pizza CreatePizza(string type)
        {
            Pizza pizza = null;

            // Define qual é a fábrica de ingredientes
            IPizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            if (type.Equals("cheese"))
            {
                // Cria uma instancia de pizza passando a fábrica de ingredientes definida (Ex.: Nova York)
                pizza      = new CheesePizza(ingredientFactory);
                pizza.Name = "Pizza de Queijo no estilo Nova York";
            }
            else if (type.Equals("clam"))
            {
                pizza      = new ClamPizza(ingredientFactory);
                pizza.Name = "Pizza de Mariscos no estilo Nova York";
            }
            // etc.

            return(pizza);
        }