Пример #1
0
        public Pizza CreatePizza(string type)
        {
            Pizza pizza = null;

            switch (type)
            {
            case "cheese":
                pizza = new CheesePizza();
                break;

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

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

            case "veggie":
                pizza = new VeggiePizza();
                break;
            }

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

            switch (type)
            {
            case "Cheese":
                pizza = new CheesePizza();
                break;

            case "Veggie":
                pizza = new VeggiePizza();
                break;

            case "Clam":
                pizza = new ClamPizza();
                break;

            case "Pepperoni":
                pizza = new PepperoniPizza();
                break;

            default:
                Console.WriteLine("Please select valid pizza type.");
                break;
            }

            // This will create my pizza based on the process defined in different pizza's
            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();

            return(pizza);
        }
Пример #3
0
        public IPizza CreatePizza(string pizzaType)
        {
            IPizza pizza = null;

            if (pizzaType.Equals("cheese"))
            {
                pizza = new CheesePizza();
            }
            else if (pizzaType.Equals("pepperoni"))
            {
                pizza = new PepperoniPizza();
            }
            else if (pizzaType.Equals("clam"))
            {
                pizza = new ClamPizza();
            }
            else if (pizzaType.Equals("veggie"))
            {
                pizza = new VeggiePizza();
            }

            return(pizza);
        }