Пример #1
0
        /// <summary>
        /// Low level concrete pizza factory method.
        /// </summary>
        /// <param name="type">Type of pizza</param>
        /// <returns>Concrete Ny Style pizza</returns>
        public override Pizza CreatePizza(string type)
        {
            Pizza pizza = null;

            switch (type.ToLower())
            {
            case "cheese":
                pizza = new NYCheesePizza();
                break;

            case "pepperoni":
                pizza = new NYPepperoniPizza();
                break;

            case "clam":
                pizza = new NYClamPizza();
                break;

            case "veggie":
                pizza = new NYVeggiePizza();
                break;

            default:
                break;
            }

            return(pizza);
        }
Пример #2
0
        protected override Pizza CreatePizza(string type)
        {
            Pizza pizza = null;

            if (type.Equals("Cheese")) { pizza = new NYCheesePizza(); }
            else if (type.Equals("Peperoni")) { pizza = new NYPepperoniPizza(); }
            else if (type.Equals("Clam")) { pizza = new NYClamPizza(); }
            else if (type.Equals("Veggie")) { pizza = new NYVeggiePizza(); }
            return pizza;
Пример #3
0
        private protected override IPizza CreatePizza(string type)
        {
            IPizza pizza = null;

            if (type.Equals("cheese"))
            {
                pizza = new NYCheesePizza();
            }
            else if (type.Equals("pepperoni"))
            {
                pizza = new NYPepperoniPizza();
            }
            else if (type.Equals("clam"))
            {
                pizza = new NYClamPizza();
            }
            else if (type.Equals("veggie"))
            {
                pizza = new NYVeggiePizza();
            }

            return(pizza);
        }