您的位置:首页 > 其它

简单工厂模式与工厂模式

2008-10-20 17:40 197 查看
工厂:

抽象工厂类

具体工厂类

抽象产品类

具体产品类

1using System;

2public abstract class Product

4public class Product1:Product

10public class Product2:Product

21public abstract class Creator

35public class Product1Creator : Creator

39public class Product2Creator : Creator

46

53public class Client

57public class SimpleFactory

2 public static void Main()

2 {

3 SimpleFactory sf = new SimpleFactory();

4 Product P = sf.Create("1");

5 P.On();

6 P.Off();

7 Console.WriteLine("-------------------------");

8 P = sf.Create("2");

9 P.On();

10 P.Off();

11 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: