Constructor overloading : Multiple constructors
The parameter lists must be unique, the same data type cannot be used more then once
New()
New(Name As String)
New(Name As String, Age As Date)
Method Overloading
A Simple Class :
Player
-HealthLevel: Integer
+ New()
+ SetHealthLevel(HealthLevel:Integer)
+SetHealthLevel(HealthLevel:Integer,Bonus:Boolean)
Code :
Private _Health As Integer
Public Sub SetHealth(HealthLevel As Integer)
_HealthLevel = HealthLevel
End Sub
Public Sub SetHealth (HealthLevel As Integer, Bonus As Boolean)
_HealthLevel = HealthLevel *2
End Sub
No comments:
Post a Comment