コード例 #1
0
        public AbstractFactoryCilent()
        {
            AbstractFactory nanChangFactory = new NanChangFactory();
            YaBo            nanChangYabo    = nanChangFactory.CreateYabo();

            nanChangYabo.Print();
            YaJia nanChangYajia = nanChangFactory.CreateYaJia();

            nanChangYajia.Print();

            AbstractFactory shangHaiFactory = new ShangHaiFactory();
            YaBo            shangHaiYabo    = shangHaiFactory.CreateYabo();

            shangHaiYabo.Print();
            YaJia shangHaiYajia = shangHaiFactory.CreateYaJia();

            shangHaiYajia.Print();

            //新增湖南
            AbstractFactory huNanFactory = new HuNanFactory();
            YaBo            huNanYabo    = huNanFactory.CreateYabo();

            huNanYabo.Print();
            YaJia huNanYajia = huNanFactory.CreateYaJia();

            huNanYajia.Print();
        }
コード例 #2
0
ファイル: CreateType.cs プロジェクト: wmchuang/DesignPattern
        public void AbstractFactoryTest()
        {
            {
                AbstractFactory nanChangFactory = new NanChangFactory();
                YaBo            nanChangYabo    = nanChangFactory.CreateYaBo();
                nanChangYabo.Print();
                YaJia nanChangYajia = nanChangFactory.CreateYaJia();
                nanChangYajia.Print();

                // 上海工厂制作上海的鸭脖和鸭架
                AbstractFactory shangHaiFactory = new ShangHaiFactory();
                shangHaiFactory.CreateYaBo().Print();
                shangHaiFactory.CreateYaJia().Print();
            }
        }
コード例 #3
0
        public void Test()
        {
            AbstractFactory nc   = new NanChangFactory();
            YaBo            ncyb = nc.CreateYaBo();

            ncyb.Print();
            YaJia ncyj = nc.CreateYaJia();

            ncyj.Print();

            AbstractFactory sh = new ShangHaiFactory();

            sh.CreateYaBo();
            sh.CreateYaJia();

            Console.ReadLine();
        }
コード例 #4
0
    static void Main(string[] args)
    {
        // 南昌工厂制作南昌的鸭脖和鸭架
        AbstractFactory nanChangFactory = new NanChangFactory();
        YaBo            nanChangYabo    = nanChangFactory.CreateYaBo();

        nanChangYabo.Print();
        YaJia nanChangYajia = nanChangFactory.CreateYaJia();

        nanChangYajia.Print();

        // 上海工厂制作上海的鸭脖和鸭架
        AbstractFactory shangHaiFactory = new ShangHaiFactory();

        shangHaiFactory.CreateYaBo().Print();
        shangHaiFactory.CreateYaJia().Print();

        Console.Read();
    }
コード例 #5
0
        private void button4_Click(object sender, EventArgs e)
        {
            // 南昌工厂制作南昌的鸭脖和鸭架
            AbstractFactory nanChangFactory = new NanChangFactory();
            YaBo            nanChangYabo    = nanChangFactory.CreateYaBo();

            nanChangYabo.Print();
            YaJia nanChangYajia = nanChangFactory.CreateYaJia();

            nanChangYajia.Print();

            // 上海工厂制作上海的鸭脖和鸭架
            AbstractFactory shangHaiFactory = new ShangHaiFactory();

            shangHaiFactory.CreateYaBo().Print();
            shangHaiFactory.CreateYaJia().Print();

            Console.Read();
        }
コード例 #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("南昌工厂创建及产品生产。");
            AbstractFactory nanChangFactory = new NanChangFactory();
            YaBo            nanChangYabo    = nanChangFactory.CreateYaBo();

            nanChangYabo.Print();
            YaJia nanChangYajia = nanChangFactory.CreateYaJia();

            nanChangYajia.Print();

            Console.WriteLine("————————————");

            Console.WriteLine("山海工厂创建及产品生产。");
            AbstractFactory shangHaiFactory = new ShangHaiFactory();

            shangHaiFactory.CreateYaBo().Print();
            shangHaiFactory.CreateYaJia().Print();

            Console.Read();
        }