摘要:(200-06-25) VB.NET 類別規劃 抽象 類別(Class)與方法(Method)
Entity Class 實體類別
UML->Domain Model
Method->行為規範(抽象描述)
Method 拆成兩個來看
- 結構 (抽象描述)
- Body
例: (飛行)
- 飛機
- 鳥 ===== > 抽出來成為 介面 Interface (飛)
- 超人
Abstract Class 特色:1.有抽像Method類別一定為抽象類別 2. 不能建構成物件
'抽象類別 有一定子類別
Public MustInherit Class Employee
'Data Field
Protected _id As String
Protected _name As String
Protected _salary As Decimal
'建構子
Public Sub New()
End Sub
'OverLoading建構子
Public Sub New(ByVal _id As String, ByVal _name As String)
Me._id = _id
Me._name = _name
End Sub
Public Property Id() As String
Get
Return _id
End Get
Set(ByVal value As String)
Me._id = value
End Set
End Property
Public Property Name() As String
Get
Return Me._name
End Get
Set(ByVal value As String)
Me._name = value
End Set
End Property
'薪資計算(有寫像沒寫 子類別都不用)
'定結構 不寫本體-描述成抽象method
Public MustOverride Sub calSalary(ByVal b As Decimal)
End Class
VB.NET 抽象類別定義:
Public MustInherit Class Employee
VB.NET 抽象方法定義:
Public MustOverride Sub calSalary(ByVal b As Decimal)