/// <summary> /// The Factory Method Pattern defines an interface /// for creating an object, but lets subclasses decide which /// class to instantiate. Factory Method lets a class defer /// instantion to subclasses. /// </summary> /// <param name="args"></param> static void Main(string[] args) { PizzaStore nyStore = new NYPizzaStore(); PizzaStore chicagoPizzaStore = new ChicagoPizzaStore(); Pizza pizza = nyStore.OrderPizza("cheese"); Console.WriteLine($"Ethan ordered a {pizza.GetName()}"); Console.WriteLine(); pizza = chicagoPizzaStore.OrderPizza("cheese"); Console.WriteLine($"Joel ordered a {pizza.GetName()}"); Console.WriteLine(); }
public static void Main(string[] args) { PizzaStore nyStore = new NyPizzaStore(); PizzaStore chicagoPizzaStore = new ChicagoPizzaStore(); Pizza pizza = nyStore.OrderPizza("cheese"); Console.WriteLine("Ethan ordered a " + pizza.GetName() + "\n"); pizza = chicagoPizzaStore.OrderPizza("cheese"); Console.WriteLine("Joel ordered a " + pizza.GetName() + "\n"); Console.ReadLine(); }
static void Main(string[] args) { SimplePizzaFactory pizzaFactory = new SimplePizzaFactory(); PizzaStore pizzaStore = new PizzaStore(pizzaFactory); Pizza pizza = pizzaStore.OrderPizza("cheese"); Console.WriteLine("A customer ordered a {0}", pizza.GetName()); Console.WriteLine(""); Console.ReadLine(); }
static void Main(string[] args) { PizzaStore dbstore = new DBPizzaStore(); //PizzaStore bjstore = new BJPizzaStore(); Pizza pizza = dbstore.OrderPizza("cheese"); Console.WriteLine(pizza.GetName()); Console.WriteLine(pizza.Prepare()); Console.WriteLine(pizza.Cut()); Console.WriteLine(pizza.Box()); Console.WriteLine(pizza.Bake()); //pizza = bjstore.OrderPizza("cheese"); //Console.WriteLine(pizza.GetName()); }