EPower2002示例:运用"工厂方法"设计类
1.新建一类库工程,命名为"VBNETDesignMode.vb"
2.将Class1.vb删除
3.在此工程中添加类,命名为"FactoryMethod.vb"
4.在"FactoryMethod.vb"中添加产品类"Product".
(1)添加三个私有成员变量:mID,mName,mCreaDate
(2)添加三个公有属性:ID,Name,CreaDate
***********************************************
FactoryMethod.vb代码如下:
***********************************************
Public Class Product '产品
'定义私有成员变量
Private mID As Integer
Private mName As String
Private mCreaDate As DateTime
'定义属性
Public Property ID() As Integer
Get
Return mID
End Get
Set(ByVal Value As Integer)
mID = Value
End Set
End Property
Public Property Name() As String
Get
Return mName
End Get
Set(ByVal Value As String)
mName = Value