Hello Aaron,
I can inherit in ONE DIRECTION
That's true.
but what about when I have a house and a car that has a DOOR? then I
need to copy and paste
No, you don't. Well, at least not completely.
Public Class Door()
Public Enum LockTypeConstants As Byte
NoLock = 0
KeyLock = 1
ElectronicLock = 2
End Enum
Public Enum MaterialConstants As Byte
NoMaterial = 0
Wood = 1
Metal = 2
Glass = 3
Plastic = 4
End Enum
Private vLockType As LockTypeConstants = LockTypeConstants.KeyLock
Private vMaterial As MaterialConstants = MaterialConstants.NoMaterial
Public Property LockType() As LockTypeSettings
Get
Return vLockType
End Get
Set (ByVal Value As LockTypeSetting)
vLockType = Value
End Set
End Property
Public Property Material() As MaterialConstants
Get
Return vMaterial
End Get
Set (ByVal Value As MaterialConstants)
vMaterial = Value
End Set
End Property
End Class
Public Class Car
Inherits VehicleWithEngine
Public [Door] As New Door
Private vDoors As Integer
Public Property Doors () As Integer
Get
Return vDoors
End Get
Set (ByVal Value As Integer)
If Value<1 Then
Err.Raise(450)
Else
vDoors = Value
End If
End Set
End Property
End Class
As you can see, I just made a public variable named "Door", which is of
the type Door. In the class "Car" I made this variable public. All the
properties of the class Door are available as part of this variable in the
class car.
Public Class House
Public [Door] As New Door
End Class
The house just got a door...and it's the same code I use.
Of course, I had to copy and paste - but only the Variable declaration,
not the code behind it. So it still saves you a lot of work.
Best regards,
Martin