static void Main(string[] args) { Pizza cheesePizza = PizzaFactory.CreatePizza("cheese"); cheesePizza.Prepare(); cheesePizza.Cut(); cheesePizza.Bake(); cheesePizza.Box(); }
public Pizza OrderPizza(string pizzaType) { Pizza pizza = CreatePizza(pizzaType); pizza.Prepare(); pizza.Bake(); pizza.Cut(); pizza.Box(); return(pizza); }
public Pizza OrderPizza(string pizzaType) { Pizza pizza = CreatePizza(pizzaType); pizza.Prepare(); // abstract factory pattern pizza.Bake(); pizza.Cut(); pizza.Box(); return(pizza); }
static void Main(string[] args) { SimplePizzaFactory factory = new SimplePizzaFactory(); PizzaStore pizzaStore = new PizzaStore(factory); Pizza pizza = pizzaStore.OrderPizza("cheese"); Console.WriteLine(pizza.Prepare() + "\n" + pizza.Bake() + "\n" + pizza.Cut() + "\n" + pizza.Box()); Console.ReadKey(); }
public void CreateGoods() { string orderType = ""; do { orderType = GetOrderType(); pizza = this.factory.CreatePizza(orderType); if (pizza != null) { pizza.Prepare(); pizza.Bake(); pizza.Cut(); pizza.Box(); } else { Console.WriteLine("没有"); break; } } while (true); }