Ejemplo n.º 1
0
        protected override Pizza CreatePizza(string pizzaType)
        {
            IPizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            Pizza pizza = null;

            switch (pizzaType)
            {
            case "cheese":
                pizza = new CheesePizza(ingredientFactory)
                {
                    Name = "NY-Style Cheese"
                };
                break;

            case "clam":
                pizza = new ClamPizza(ingredientFactory)
                {
                    Name = "NY-Style Clam"
                };
                break;

            default:
                break;
            }

            return(pizza);
        }
Ejemplo n.º 2
0
        protected override PizzaBase CreatePizza(string type)
        {
            PizzaBase pizza = null;
            NYPizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            switch (type)
            {
            case "cheese":
                pizza = new CheesePizza(ingredientFactory)
                {
                    Name = "NY Style Cheese Pizza"
                };
                break;

            case "clam":
                pizza = new ClamPizza(ingredientFactory)
                {
                    Name = "NY Style Clam Pizza"
                };
                break;

            default:
                return(null);
            }

            return(pizza);
        }
        protected override Pizza CreatePizza(string type)
        {
            Pizza pizza = null;
            PizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            switch (type)
            {
                case "Cheese":
                    pizza = new CheesePizza(ingredientFactory);
                    pizza.Name = "NY Style Cheese Pizza";
                    break;
                case "Pepperoni":
                    pizza = new PepperoniPizza(ingredientFactory);
                    pizza.Name = "NY Style Pepperoni Pizza";
                    break;
                case "Clam":
                    pizza = new ClamPizza(ingredientFactory);
                    pizza.Name = "NY Style Clam Pizza";
                    break;
                case "Veggie":
                    pizza = new VeggiePizza(ingredientFactory);
                    pizza.Name = "NY Style Veggie Pizza";
                    break;
            }

            return pizza;
        }
Ejemplo n.º 4
0
        protected override Pizza CreatePizza(string item)
        {
            Pizza pizza             = null;
            var   ingredientFactory = new NYPizzaIngredientFactory();

            switch (item)
            {
            case "cheese":
                pizza      = new CheesePizza(ingredientFactory);
                pizza.Name = "New York Style Cheese Pizza";
                break;

            case "pepperoni":
                pizza      = new PepperoniPizza(ingredientFactory);
                pizza.Name = "New York Style Pepperoni Pizza";
                break;

            case "clam":
                pizza      = new ClamPizza(ingredientFactory);
                pizza.Name = "New York Style Clam Pizza";
                break;

            case "veggie":
                pizza      = new VeggiePizza(ingredientFactory);
                pizza.Name = "New York Style Veggie Pizza";
                break;
            }

            return(pizza);
        }
Ejemplo n.º 5
0
        protected override Pizza createPizza(string item)
        {
            Pizza pizza = null;

            // Фабрика производит ингредиенты для всех пицц в Нью-Йоркском стиле
            IPizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            if (item.Equals("cheese"))
            {
                pizza      = new CheesePizza(ingredientFactory);
                pizza.name = "Нью-Йоркская с сыром";
            }
            else if (item.Equals("veggie"))
            {
                pizza      = new VeggiePizza(ingredientFactory);
                pizza.name = "Нью-Йоркская Вегетарианская";
            }
            else if (item.Equals("clam"))
            {
                pizza      = new ClamPizza(ingredientFactory);
                pizza.name = "Нью-Йоркская с мидиями";
            }
            else if (item.Equals("pepperoni"))
            {
                pizza      = new PepperoniPizza(ingredientFactory);
                pizza.name = "Нью-Йоркская Пепперони";
            }
            return(pizza);
        }
        protected override Pizza CreatePizza(PizzaType type)
        {
            IPizzaIngredientFactory ingredient = new NYPizzaIngredientFactory();

            switch (type)
            {
                case PizzaType.Cheese:
                {
                    Pizza pizza = new CheesePizza(ingredient);
                    pizza.Name = "NY style Cheese Pizza";
                    return pizza;
                }
                case PizzaType.Calm:
                {
                    return new NYStyleCalmPizza();
                }
                case PizzaType.Pepperoni:
                {
                    return new NYStylePepperoniPizza();
                }
                case PizzaType.Veggie:
                {
                    return new NYStyleVeggiePizza();
                }
                default:
                {
                    return null;
                }
            }
        }
Ejemplo n.º 7
0
        protected override Pizza createPizza(string item)
        {
            Pizza pizza = null;
            PizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            if (item.Equals("cheese"))
            {
                pizza = new CheesePizza(ingredientFactory);
                pizza.setName("纽约风格芝士披萨");
            }
            else if (item.Equals("veggie"))
            {
                pizza = new VeggiePizza(ingredientFactory);
                pizza.setName("纽约风格素食披萨");
            }
            else if (item.Equals("clam"))
            {
                pizza = new ClamPizza(ingredientFactory);
                pizza.setName("纽约风格蛤蜊披萨");
            }
            else if (item.Equals("pepperoni"))
            {
                pizza = new PepperoniPizza(ingredientFactory);
                pizza.setName("纽约风格意大利辣香肠披萨");
            }

            return(pizza);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// This subclass handles object instantiation for us in the createPizza() method
        /// Encapsulates all the knowledge about how to make NY style pizzas
        /// </summary>
        public override Pizza createPizza(string type)
        {
            Pizza pizza = null;
            IPizzaIngredientFactory ingredientFactory =
                new NYPizzaIngredientFactory();

            if (type == "cheese")
            {
                pizza = new CheesePizza(ingredientFactory);
                pizza.setName("NY Style Cheese Pizza.");
            }
            else if (type == "veggie")
            {
                pizza = new VeggiePizza(ingredientFactory);
                pizza.setName("NY Style Veggie Pizza.");
            }
            else if (type == "clam")
            {
                pizza = new ClamPizza(ingredientFactory);
                pizza.setName("NY Style Clam Pizza.");
            }
            else if (type == "pepperoni")
            {
                pizza = new PepperoniPizza(ingredientFactory);
                pizza.setName("NY Style Pepperoni Pizza.");
            }
            return(pizza);
        }
Ejemplo n.º 9
0
        protected override Pizza CreatePizza(PizzaType type)
        {
            var factory  = new NYPizzaIngredientFactory();
            var behavior = new NYPizzaCookBehavior();

            switch (type)
            {
            case PizzaType.Cheese:
                return(new CheesePizza(factory, behavior)
                {
                    Name = "NY Cheese Pizza"
                });

            case PizzaType.Clam:
                return(new ClamPizza(factory, behavior)
                {
                    Name = "NY Clam Pizza"
                });

            case PizzaType.Pepperoni:
                return(new PepperoniPizza(factory, behavior)
                {
                    Name = "NY Pepperoni Pizza"
                });

            case PizzaType.Veggie:
                return(new VeggiePizza(factory, behavior)
                {
                    Name = "NY Veggie Pizza"
                });

            default:
                throw new ArgumentException();
            }
        }
Ejemplo n.º 10
0
        public override Pizza CreatePizza(PizzaType type)
        {
            Pizza pizza;
            IPizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            switch (type)
            {
            case PizzaType.Cheese:
                pizza = new CheesePizza(ingredientFactory)
                {
                    Name = "New York Style Cheese Pizza"
                };
                break;

            case PizzaType.Clam:
                pizza = new ClamPizza(ingredientFactory)
                {
                    Name = "New York Style Clam Pizza"
                };
                break;

            case PizzaType.Veggie:
            case PizzaType.Pepperoni:
            default:
                throw new ArgumentException("Wrong type of pizza");
            }

            return(pizza);
        }
        protected override Pizza CreatePizza(string type)
        {
            Pizza pizza = null;
            IPizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            if (type == "cheese")
            {
                pizza      = new CheesePizza(ingredientFactory);
                pizza.Name = "New York Style Cheese Pizza";
            }
            else if (type == "pepperoni")
            {
                pizza      = new VeggiePizza(ingredientFactory);
                pizza.Name = "New York Style Veggie Pizza";
            }
            else if (type == "clam")
            {
                pizza      = new ClamPizza(ingredientFactory);
                pizza.Name = "New York Style Clam Pizza";
            }
            else if (type == "veggie")
            {
                pizza      = new VeggiePizza(ingredientFactory);
                pizza.Name = "New York Style Veggie Pizza";
            }

            return(pizza);
        }
Ejemplo n.º 12
0
        public override Pizza CreatePizza(PizzaType pizzaType)
        {
            Pizza pizza = null;

            IPizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            if (pizzaType == PizzaType.Cheese)
            {
                pizza      = new CheesePizza(ingredientFactory);
                pizza.Name = "New York Cheese Pizza";
            }
            else if (pizzaType == PizzaType.Veggie)
            {
                pizza = new VeggiePizza(ingredientFactory);
            }
            else if (pizzaType == PizzaType.Pepperoni)
            {
                pizza = new PepperoniPizza(ingredientFactory);
            }
            else if (pizzaType == PizzaType.Clam)
            {
                pizza = new ClamPizza(ingredientFactory);
            }

            return(pizza);
        }
        public override Pizza CreatePizza(string pizzaType)
        {
            Pizza pizza = null;
            IPizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            switch (pizzaType)
            {
            case "cheese":
                pizza = new CheesePizza(ingredientFactory);
                pizza.SetName("New York Style Cheese Pizza");
                break;

            case "veggie":
                pizza = new VeggiePizza(ingredientFactory);
                pizza.SetName("New York Style Veggie Pizza");
                break;

            case "clam":
                pizza = new ClamPizza(ingredientFactory);
                pizza.SetName("New York Style Clam Pizza");
                break;

            case "pepperoni":
                pizza = new PepperoniPizza(ingredientFactory);
                pizza.SetName("New York Style Pepperoni Pizza");
                break;
            }

            return(pizza);
        }
Ejemplo n.º 14
0
        protected internal override Pizza CreatePizza(string item)
        {
            Pizza pizza = null;
            PizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            if (item.Equals("cheese"))
            {
                pizza      = new CheesePizza(ingredientFactory);
                pizza.Name = "New York Style Cheese Pizza";
            }
            else if (item.Equals("veggie"))
            {
                pizza      = new VeggiePizza(ingredientFactory);
                pizza.Name = "New York Style Veggie Pizza";
            }
            else if (item.Equals("clam"))
            {
                pizza      = new ClamPizza(ingredientFactory);
                pizza.Name = "New York Style Clam Pizza";
            }
            else if (item.Equals("pepperoni"))
            {
                pizza      = new PepperoniPizza(ingredientFactory);
                pizza.Name = "New York Style Pepperoni Pizza";
            }
            return(pizza);
        }
Ejemplo n.º 15
0
        protected override PizzaBase CreatePizza(PizzaType type)
        {
            PizzaBase pizza = null;
            IPizzaIngredientFactory factory = new NYPizzaIngredientFactory();

            switch (type)
            {
            case PizzaType.Cheese:
            {
                pizza = new CheesePizza(factory);
                pizza.SetName("New York Style Cheese Pizza");
                break;
            }

            case PizzaType.Pepperoni:
            {
                pizza = new PepperoniPizza(factory);
                pizza.SetName("New York Style Pepperoni Pizza");
                break;
            }

            case PizzaType.Special:
            {
                pizza = new CurrentSpecialPizza(factory);
                pizza.SetName("New York Pizza Special!");
                break;
            }

            default:
                throw new ArgumentException("Invalid Pizza type given");
            }

            return(pizza);
        }
Ejemplo n.º 16
0
        public override Pizza CreatePizza(string type)
        {
            Pizza pizza = null;
            IPizzaIngredientFactory pizzaIngredientFactory = new NYPizzaIngredientFactory();

            if (type == "cheese")
            {
                pizza = new CheesePizza(pizzaIngredientFactory);
                pizza.SetName("New York Style Cheese Pizza");
            }
            else if (type == "clam")
            {
                pizza = new ClamPizza(pizzaIngredientFactory);
                pizza.SetName("New York Style Clam Pizza");
            }
            else if (type == "pepperoni")
            {
                pizza = new PepperoniPizza(pizzaIngredientFactory);
                pizza.SetName("New York Style Pepperoni Pizza");
            }
            else
            {
                return(null);
            }
            return(pizza);
        }
Ejemplo n.º 17
0
        protected override Pizza.Pizza CreatePizza(String item)
        {
            Pizza.Pizza pizza;

            IPizzaIngredientFactory pizzaIngredientFactory = new NYPizzaIngredientFactory();

            switch (item)
            {
            case "cheese":
            {
                pizza = new CheesePizza(pizzaIngredientFactory);
                return(pizza);
            }

            case "clam":
            {
                pizza = new ClamPizza(pizzaIngredientFactory);
                return(pizza);
            }

            default:
            {
                return(null);
            }
            }
        }
Ejemplo n.º 18
0
        public override Pizza CreatePizza(string type)
        {
            PizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            if (type.Equals("cheese"))
            {
                return(new NYStyleCheesePizza(ingredientFactory));
            }
            else if (type.Equals("pepperoni"))
            {
                return(new NYStylePepperoniPizza(ingredientFactory));
            }
            else if (type.Equals("clam"))
            {
                return(new NYStyleClamPizza(ingredientFactory));
            }
            else if (type.Equals("veggie"))
            {
                return(new NYStyleVeggiePizza(ingredientFactory));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 19
0
        public override Pizza createPizza(String item)
        {
            Pizza pizza = null;
            PizzaIngredientFactory ingredientFactory =
                new NYPizzaIngredientFactory();

            if (item.Equals("cheese"))
            {
                pizza = new CheesePizza(ingredientFactory);
                pizza.setName("New York Style Cheese Pizza");
            }
            else if (item.Equals("veggie"))
            {
                pizza = new VeggiePizza(ingredientFactory);
                pizza.setName("New York Style Veggie Pizza");
            }
            else if (item.Equals("clam"))
            {
                pizza = new ClamPizza(ingredientFactory);
                pizza.setName("New York Style Clam Pizza");
            }
            else if (item.Equals("pepperoni"))
            {
                pizza = new PepperoniPizza(ingredientFactory);
                pizza.setName("New York Style Pepperoni Pizza");
            }
            return(pizza);
        }
        protected override Pizza createPizza(string type)
        {
            var   ingredientFactory = new NYPizzaIngredientFactory();
            Pizza pizza             = null;
            var   pizzaType         = type.ToLower();

            switch (pizzaType)
            {
            case "cheese":
                pizza      = new CheesePizza(ingredientFactory);
                pizza.Name = "New York Style Cheese Pizza";
                break;

            case "pepperoni":
                pizza      = new PepperoniPizza(ingredientFactory);
                pizza.Name = "New York Style Pepperoni Pizza";
                break;

            case "clam":
                pizza      = new ClamsPizza(ingredientFactory);
                pizza.Name = "New York Style Clam Pizza";
                break;

            case "veggie":
                pizza      = new VeggiePizza(ingredientFactory);
                pizza.Name = "New York Style Veggie Pizza";
                break;
            }

            return(pizza);
        }
Ejemplo n.º 21
0
        protected override Pizza CreatePizza(string item) {
            Pizza pizza = null;
            IPizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            if (item.Equals("cheese")) {
                pizza = new CheesePizza(ingredientFactory);
                pizza.SetName("New York style cheese pizza");
            }

            return pizza;
        }
Ejemplo n.º 22
0
        protected override Pizza createPizza(string type)
        {
            PizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            if (type.Equals("cheese"))
            {
                return(new NYStyleCheesePizza(ingredientFactory));
            }

            return(null);
        }
Ejemplo n.º 23
0
        protected override Pizza CreatePizza(string item)
        {
            Pizza pizza = null;
            IPizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            if (item.Equals("cheese"))
            {
                pizza = new CheesePizza(ingredientFactory);
                pizza.SetName("New York style cheese pizza");
            }

            return(pizza);
        }
Ejemplo n.º 24
0
        public override Pizza CreatePizza(string typeOfPizza)
        {
            Pizza pizza = null;
            PizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            if (typeOfPizza.Equals("cheese"))
            {
                pizza      = new CheesePizza(ingredientFactory);
                pizza.Name = "New York Style Cheese Pizza";
            }

            return(pizza);
        }
Ejemplo n.º 25
0
        public override Pizza CreatePizza(string item)
        {
            Pizza pizza = null;
            IPizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            if (item.Equals("cheese"))
            {
                pizza = new CheesePizza(ingredientFactory)
                {
                    name = "New York Style Chesse Pizza."
                };
            }

            return(pizza);
        }
Ejemplo n.º 26
0
        protected override Pizza createPizza(string type)
        {
            IPizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            switch (type)
            {
            case "cheese": return(new NYStyleCheesePizza(ingredientFactory));

            case "pepperoni": return(new NYStylePepperoniPizza(ingredientFactory));

            case "vegan": return(new NYStyleVeganPizza(ingredientFactory));

            default: throw new ArgumentException("Incorrect type of pizza");
            }
        }
Ejemplo n.º 27
0
        private void FactoryTest_Click(object sender, RoutedEventArgs e)
        {
            var nyPizzaIngredientFactory = new NYPizzaIngredientFactory();
            var nyPizzaStore             = new NYStylePizzaStore(nyPizzaIngredientFactory);
            var chicagopizzaStore        = new ChicagoStylePizzaStore(nyPizzaIngredientFactory);

            Console.WriteLine();
            var pizza1 = nyPizzaStore.OrderPizza("cheese");

            Console.WriteLine($"1つ目の注文は {pizza1.Name} です");

            Console.WriteLine();
            var pizza2 = chicagopizzaStore.OrderPizza("cheese");

            Console.WriteLine($"2つ目の注文は {pizza2.Name} です");
        }