コード例 #1
0
        protected override Pizza Create(string type)
        {
            Pizza pizza;
            IFactoryIngredients ingredients = new PizzaAIngredients();

            if (type.Equals("Cheese"))
            {
                pizza = new CheesePizza(ingredients)
                {
                    Name = "Pizzeria A Style Cheese"
                };
            }
            else if (type.Equals("Clam"))
            {
                pizza = new ClamPizza(ingredients)
                {
                    Name = "Pizzeria A Style Clam"
                };
            }
            else
            {
                pizza = new VeggiePizza(ingredients)
                {
                    Name = "Pizzeria A Style Veggie"
                };
            }
            pizza.Color = "red";
            return(pizza);
        }
コード例 #2
0
        protected override Pizza Create(string type)
        {
            Pizza pizza;
            IFactoryIngredients ingredients = new PizzaBIngredients();

            if (type.Equals("Cheese"))
            {
                pizza      = new CheesePizza(ingredients);
                pizza.Name = "Pizzeria B Cheese";
            }
            else if (type.Equals("Clam"))
            {
                pizza      = new ClamPizza(ingredients);
                pizza.Name = "Pizzeria B Clam";
            }
            else
            {
                pizza      = new VeggiePizza(ingredients);
                pizza.Name = "Pizzeria B Veggie";
            }
            pizza.Color = "green";
            return(pizza);
        }