Esempio n. 1
0
        static void Main(string[] args)
        {
            Creator shreddedPorkWithPotatoesFactory = new ShreddedPorkWithPotatoesFactory();
            Creator tomatoScrambledEggsFactory = new TomatoScrambledEggsFactory();

            //开始做西红柿
            Food tomatoScrambleEggs = tomatoScrambledEggsFactory.CreateFoddFactory();
            tomatoScrambleEggs.Print();
            //开始做土豆丝
            Food shreddedPorkWithPotatoes = shreddedPorkWithPotatoesFactory.CreateFoddFactory();
            shreddedPorkWithPotatoes.Print();

            Console.Read();
        }
Esempio n. 2
0
        static void Main()
        {
            // 初始化做菜的两个工厂
            Creator tomatoScrambledEggsFactory      = new TomatoScrambledEggsFactory();
            Creator shreddedPorkWithPotatoesFactory = new ShreddedPorkWithPotatoesFactory();

            // 开始做番茄炒蛋
            Food tomatoScrambledEggs = tomatoScrambledEggsFactory.CreateFoodFactory();

            tomatoScrambledEggs.Print();
            // 开始做土豆肉丝
            Food shreddedPorkWithPotatoes = shreddedPorkWithPotatoesFactory.CreateFoodFactory();

            shreddedPorkWithPotatoes.Print();

            // 想增加肉末茄子这道菜
            Creator roumoqieziFactory = new RoumoqieziFactory();
            Food    roumoqiezi        = roumoqieziFactory.CreateFoodFactory();

            roumoqiezi.Print();
        }