예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            AbstractFactory jiangxiFactory = new JiangXiFactory();
            YaBo            jiangxiYabo    = jiangxiFactory.CreateYaBo();

            label1.Text = jiangxiYabo.Print();

            YaJiao jiangxiYajiao = jiangxiFactory.CreateYaJiao();

            label2.Text = jiangxiYajiao.Print();
        }
예제 #2
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();
        }