Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Help with Object that contains 2 other objects vb.net

pdidowpdidow Posts: 4Member
I have 3 classes. They are called Boot,Head,and Shell. A boot contains both a Set of Head objects and a set of Shell objects.
My classes:

Head.vb
-------------
[code]
Option Explicit On
Public Class Head
Inherits BusinessEntity.HeadSet
#Region "Private Variables"
Private _iVesselID As Integer
Private _iHeadID As Integer
#End Region

#Region "Constructors"
Public Sub New()

End Sub
Public Sub New(ByVal iVesselID As Integer, ByVal iHeadID As Integer)
_iVesselID = iVesselID
_iHeadID = iHeadID
End Sub
#End Region

#Region "Public Properties"
Public Property iVesselID() As Integer
Get
Return _iVesselID
End Get
Set(ByVal iValue As Integer)
_iVesselID = iValue
End Set
End Property
Public Property iHeadID() As Integer
Get
Return _iHeadID
End Get
Set(ByVal iValue As Integer)
_iHeadID = iValue
End Set
End Property
#End Region

End Class
Public Class HeadSet
Inherits Collections.ArrayList

Public Shadows Function Add(ByVal oValue As Head) As Integer
If Not oValue Is Nothing Then
MyBase.Add(oValue)
End If
End Function

Default Public Shadows Property Item(ByVal iIndex As Integer) As Head
Get
Return CType(MyBase.Item(iIndex), Head)

End Get
Set(ByVal Value As Head)
MyBase.Item(iIndex) = Value
End Set
End Property

End Class
[/code]
Shell.vb
------------
[code]
Option Explicit On
Public Class Shell
Inherits BusinessEntity.ShellSet

#Region "Private Variables"
Private _iVesselID As Integer
Private _iShellID As Integer
#End Region

#Region "Constructors"
Public Sub New()

End Sub
Public Sub New(ByVal iVesselID As Integer, ByVal iShellID As Integer)
_iVesselID = iVesselID
_iShellID = iShellID
End Sub
#End Region

#Region "Public Properties"
Public Property iVesselID() As Integer
Get
Return _iVesselID
End Get
Set(ByVal iValue As Integer)
_iVesselID = iValue
End Set
End Property
Public Property iShellID() As Integer
Get
Return _iShellID
End Get
Set(ByVal iValue As Integer)
_iShellID = iValue
End Set
End Property
#End Region
End Class

Public Class ShellSet
Inherits Collections.ArrayList

Public Shadows Function Add(ByVal oValue As Shell) As Integer
If Not oValue Is Nothing Then
MyBase.Add(oValue)
End If
End Function

Default Public Shadows Property Item(ByVal iIndex As Integer) As Shell
Get
Return CType(MyBase.Item(iIndex), Shell)

End Get
Set(ByVal Value As Shell)
MyBase.Item(iIndex) = Value
End Set
End Property

End Class

[/code]
And Boot.vb
-------------
[code]
Option Explicit On
Public Class Boot
'Contains a head and shell
#Region "Private Variables"
Private _oHeadSet As New HeadSet
Private _oShellSet As New ShellSet
Private _iBootID As Integer
Private _iVesselID As Integer
#End Region

#Region "Constructors"
Public Sub New()
_oHeadSet = New BusinessEntity.HeadSet
Dim oHead As New Head
_oHeadSet.Add(oHead)
_oShellSet = New BusinessEntity.ShellSet
Dim oShell As New Shell
_oShellSet.Add(oShell)

End Sub
Public Sub New(ByVal oHeadSet As HeadSet, ByVal oShellSet As ShellSet, ByVal iBootID As Integer, ByVal iVesselID As Integer)
_oHeadSet = New BusinessEntity.HeadSet
_oShellSet = New BusinessEntity.ShellSet
Dim oHead As New Head
Dim oShell As New Shell
_oHeadSet.Add(oHead)
_oShellSet.Add(oShell)
_iBootID = iBootID
_iVesselID = iVesselID

End Sub
#End Region

#Region "Public Properties"
Public Property oHeadSet() As BusinessEntity.HeadSet
Get
Return _oHeadSet
End Get
Set(ByVal oValue As HeadSet)
_oHeadSet = oValue
End Set
End Property

Public Property oShellSet() As BusinessEntity.ShellSet
Get
Return _oShellSet
End Get
Set(ByVal oValue As ShellSet)
_oShellSet = oValue
End Set
End Property

Public Property iBootID() As Integer
Get
Return _iBootID
End Get
Set(ByVal iValue As Integer)
_iBootID = iValue
End Set
End Property

Public Property iVesselID() As Integer
Get
Return _iVesselID
End Get
Set(ByVal iValue As Integer)
_iVesselID = iValue
End Set
End Property
#End Region
End Class


Public Class BootSet
Inherits Collections.ArrayList

Public Shadows Function Add(ByVal oValue As Boot) As Integer
If Not oValue Is Nothing Then
MyBase.Add(oValue)

End If
End Function

Default Public Shadows Property Item(ByVal iIndex As Integer) As Boot
Get
Return CType(MyBase.Item(iIndex), Boot)

End Get
Set(ByVal Value As Boot)
MyBase.Item(iIndex) = Value
End Set
End Property

End Class

[/code]
And a function from my code behind webpage, to implement
[code]
Public Function BuildEM() As BusinessEntity.BootSet
oHead = New BusinessEntity.Head
oHeadSet = New BusinessEntity.HeadSet
oShell = New BusinessEntity.Shell
oShellSet = New BusinessEntity.ShellSet
oBootSet = New BusinessEntity.BootSet

oHead.iHeadID = 1
oHeadSet.Add(oHead)
oShell.iShellID = 1
oShellSet.Add(oShell)
oBoot = New BusinessEntity.Boot

oBoot.iBootID = 1

oBoot.iVesselID = 30

oBootSet.Add(oBoot)
Return oBootSet
End Function
[/code]
What is in the returned oBootSet is not what I expect.
I have a bootset returned, containing a headset and a shellset. There are no items in this set, as my watch indicates:
- oBootSet Count = 1 BusinessEntity.BootSet
- (0) {BusinessEntity.Boot} Object
- BusinessEntity.Boot {BusinessEntity.Boot} BusinessEntity.Boot
_iBootID 1 Integer
_iVesselID 30 Integer
- _oHeadSet Count = 1 BusinessEntity.HeadSet
(0) Count = 0 Object
- _oShellSet Count = 1 BusinessEntity.ShellSet
(0) Count = 0 Object
iBootID 1 Integer
iVesselID 30 Integer
- oHeadSet Count = 1 BusinessEntity.HeadSet
(0) Count = 0 Object
- oShellSet Count = 1 BusinessEntity.ShellSet
(0) Count = 0 Object


What am i doing wrong?Please Help!!

Sign In or Register to comment.