예제 #1
0
        private static void Main(string[] args)
        {
            // 初始化做菜的两个工厂()
            Creator shreddedPorkWithPotatoesFactory = new ShreddedPorkWithPotatoesFactory();
            Creator tomatoScrambledEggsFactory      = new TomatoScrambledEggsFactory();

            // 开始做西红柿炒蛋
            AbstractFood tomatoScrambleEggs = tomatoScrambledEggsFactory.CreateFoddFactory();

            tomatoScrambleEggs.Print();

            //开始做土豆肉丝
            AbstractFood shreddedPorkWithPotatoes = shreddedPorkWithPotatoesFactory.CreateFoddFactory();

            shreddedPorkWithPotatoes.Print();

            // 如果客户又想点肉末茄子了
            // 再另外初始化一个肉末茄子工厂
            Creator minceMeatEggplantFactor = new MincedMeatEggplantFactory();

            // 利用肉末茄子工厂来创建肉末茄子这道菜
            AbstractFood minceMeatEggplant = minceMeatEggplantFactor.CreateFoddFactory();

            minceMeatEggplant.Print();
            Console.Read();
        }
예제 #2
0
        static void Main(string[] args)
        {
            var shreddedPorkWithPotatoesFactory = new ShreddedPorkWithPotatoesFactory();
            var tomatoScrambledEggsFactory      = new TomatoScrambledEggsFactory();

            var tomatoFactory = tomatoScrambledEggsFactory.CreateFoodFactory();

            tomatoFactory.Print();

            var shreddedFactory = shreddedPorkWithPotatoesFactory.CreateFoodFactory();

            shreddedFactory.Print();
        }
예제 #3
0
파일: Program.cs 프로젝트: weiliji/.net
        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();

        }
예제 #4
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();
        }