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

            if (type.Equals("Cheese"))
            {
                pizza      = new CheesePizza(ingredientFactory);
                pizza.Name = "New York Style Cheese Pizza";
            }
            else if (type.Equals("Clam"))
            {
                pizza      = new ClamPizza(ingredientFactory);
                pizza.Name = "New York Style Clam Pizza";
            }

            return(pizza);
        }
Exemple #2
0
        static void Main(string[] args)
        {
            PizzaStore NYStore = new NYPizzaStore();
            Pizza      pizza   = NYStore.OrderPizza("Cheese");

            Console.WriteLine("Ethan order a " + pizza.Name + "\n");

            Console.WriteLine("---------------------------------------------------\n");

            PizzaStore ChicargoStore = new ChicagoPizzaStore();

            pizza = ChicargoStore.OrderPizza("Clam");
            Console.WriteLine("Joel ordered a " + pizza.Name + "\n");


            Console.WriteLine("-----------------------------------\n");

            //SimplePizzaFactory simpleFactory = new SimplePizzaFactory();

            //SimplePizzaStore simpleStore = new SimplePizzaStore(simpleFactory);

            //pizza = simpleStore.OrderPizza("Cheese");


            //Console.WriteLine("Martin ordered a " + pizza.Name + "\n");

            Console.WriteLine("SimpleFactory Use static\n");

            SimplePizzaStore simpleStore = new SimplePizzaStore();

            pizza = simpleStore.OrderPizza("Cheese");
            Console.WriteLine("Martin ordered a " + pizza.Name + "\n");


            Console.WriteLine("------------------------------------\n");

            Console.WriteLine("Abstract Factory with Ingredient \n");

            PizzaStoreFromAF nyStore = new NYPizzaStoreFromAF();
            PizzaFromAF      pizzaAF = nyStore.OrderPizza("Cheese");


            Console.WriteLine("Amy ordered a " + pizzaAF.Name + " \n");
        }