Пример #1
0
        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);
        }
Пример #3
0
        public Pizza OrderPizza(string pizzaType)
        {
            Pizza pizza = CreatePizza(pizzaType);

            pizza.Prepare(); // abstract factory pattern
            pizza.Bake();
            pizza.Cut();
            pizza.Box();

            return(pizza);
        }
Пример #4
0
        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();
        }
Пример #5
0
        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);
        }