Example #1
0
        public override Pizza createPizza(string type)
        {
            Pizza pizza = null;
            PizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            if (type.Equals("cheese"))
            {
                pizza      = new NYStyleCheesePizza(ingredientFactory);
                pizza.name = "New York Style Cheese Pizza";
            }
            else if (type.Equals("pepperoni"))
            {
                pizza      = new PepperoniPizza(ingredientFactory);
                pizza.name = "New York Style Pepperoni Pizza";
            }
            else if (type.Equals("clam"))
            {
                pizza      = new ClamPizza(ingredientFactory);
                pizza.name = "New York Style Clam Pizza";
            }
            else if (type.Equals("veggie"))
            {
                pizza      = new VeggiePizza(ingredientFactory);
                pizza.name = "New York Style Veggie Pizza";
            }

            return(pizza);
        }
        public Pizza CreatePizza(params string[] myType)
        {
            Pizza  pizza = null;
            string type  = "";

            if (myType.Length > 0)
            {
                type = myType[0];
            }
            else
            {
                type = "Cheese";
            }

            if (type == "Cheese")
            {
                pizza = new CheesePizza();
            }
            else if (type == "PepperoniPizza")
            {
                pizza = new PepperoniPizza();
            }
            else if (type == "VeggiePizza")
            {
                pizza = new VeggiePizza();
            }

            return(pizza);
        }
Example #3
0
        protected override Pizza CreatePizza(PizzaType type)
        {
            Pizza pizza = null;
            IPizzaIngredientFactory ingredientFactory = new NYPizzaIngredientFactory();

            switch (type)
            {
            case PizzaType.Cheese:
                pizza = new CheesePizza(ingredientFactory);
                pizza.SetName(style + "Cheese Pizza");
                break;

            case PizzaType.Clam:
                pizza = new ClamPizza(ingredientFactory);
                pizza.SetName(style + "Clam Pizza");
                break;

            case PizzaType.Veggie:
                pizza = new VeggiePizza(ingredientFactory);
                pizza.SetName(style + "Veggie Pizza");
                break;

            case PizzaType.Pepperoni:
                pizza = new PepperoniPizza(ingredientFactory);
                pizza.SetName(style + "Pepperoni Pizza");
                break;
            }

            return(pizza);
        }
Example #4
0
        public Pizza CreatePizza(params string[] type)
        {
            Random random = new Random();
            int    r      = random.Next(11);
            Pizza  pizza  = null;

            if (r == 0 || r == 2 || r == 3)
            {
                pizza = new CheesePizza();
            }
            else if (r == 1 || r == 5)
            {
                pizza = new PepperoniPizza();
            }
            else
            {
                pizza = new VeggiePizza();
            }
            return(pizza);
        }
        public Pizza createPizza(String type)
        {
            Pizza pizza = null;

            if (type.Equals("cheese"))
            {
                pizza = new CheesePizza();
            }
            else if (type.Equals("pepperoni"))
            {
                pizza = new PepperoniPizza();
            }
            else if (type.Equals("clam"))
            {
                pizza = new ClamPizza();
            }
            else if (type.Equals("veggie"))
            {
                pizza = new VeggiePizza();
            }
            return(pizza);
        }
        /// <summary>
        /// Returns a pizza based on the provided type
        /// </summary>
        /// <param name="type">The type of piza requested</param>
        /// <returns>The pizza requested</returns>
        public IPizza CreatePizza(PizzaTypes type)
        {
            IPizza pizza = null;

            var loggerFactory = new LoggerFactory();

            switch (type)
            {
            case PizzaTypes.Margarita:
                pizza = new MargaritaPizza(loggerFactory.CreateLogger <IPizza>());
                break;

            case PizzaTypes.Pepperoni:
                pizza = new PepperoniPizza(loggerFactory.CreateLogger <IPizza>());
                break;

            default:
                throw new ArgumentException();
            }

            return(pizza);
        }