1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
Public MustInherit Class JoyPak
Protected _A, _B As String
Protected _X, _Y As Double
Protected _K As Double
Public Overridable Sub Proc1()
Throw New NotImplementedException("Cette procédure n'est pas implémentée")
End Sub
Public Overridable Sub Proc2()
Throw New NotImplementedException("Cette procédure n'est pas implémentée")
End Sub
Public Overridable Sub Proc3()
Throw New NotImplementedException("Cette procédure n'est pas implémentée")
End Sub
End Class
Public Class JoyPak1
Inherits JoyPak
Public Overrides Sub Proc1()
' Mon Code
End Sub
Public Overrides Sub Proc2()
' Mon Code
End Sub
Sub New(ByVal x As Double, ByVal y As Double)
_X = x : _Y = y
End Sub
End Class
Public Class JoyPak2
Inherits JoyPak
Public Overrides Sub Proc3()
' Mon Code
End Sub
Sub New(ByVal a As String, ByVal b As String, ByVal k As Double)
_A = a : _B = b
_K = k
End Sub
End Class
' Utilisation
Dim Var1 As JoyPak = New JoyPak1(12.5, 15.0)
Dim Var2 As JoyPak = New JoyPak2("truc", "bidule", 76.325)
Messagebox.show (var1.proc1) ' OK
Messagebox.show (var1.proc2) ' OK
Messagebox.show (var1.proc3) ' NotImplementedException
Messagebox.show (var2.proc1) ' NotImplementedException
Messagebox.show (var2.proc2) ' NotImplementedException
Messagebox.show (var2.proc3) ' OK |
Partager