Multiple classes with a class 
Author Message
 Multiple classes with a class

Hi Guys,

I am trying to write a VB.NET app that is real world
modelled by have one class (the aeroplane class) that
contains several instances of another class (the
passenger class).  Please can someone explain
to me how I should model with in VB.NET.  I can't
seem to find any good help on the subject or I am
not looking in the correct place.

Any help is much appreciated.

Regards,

Jason.



Sat, 10 Sep 2005 00:38:18 GMT  
 Multiple classes with a class
Hello Jason,


Quote:
> I am trying to write a VB.NET app that is real world
> modelled by have one class (the aeroplane class) that
> contains several instances of another class (the
> passenger class).  Please can someone explain

Use an ArrayList to hold the instances of Passenger. Then you can
provide a public indexed property to access the passenger objects.

Regards,
Herfried K. Wagner



Sat, 10 Sep 2005 01:11:26 GMT  
 Multiple classes with a class
Thanks for the info.  Is there an online resource
that will provide me with the implementation
detiails for ArrayLists of object instances?

Thanks
JJ

Quote:
>Hello Jason,


>> I am trying to write a VB.NET app that is real world
>> modelled by have one class (the aeroplane class) that
>> contains several instances of another class (the
>> passenger class).  Please can someone explain

>Use an ArrayList to hold the instances of Passenger. Then you can
>provide a public indexed property to access the passenger objects.

>Regards,
>Herfried K. Wagner



Sat, 10 Sep 2005 01:23:38 GMT  
 Multiple classes with a class
Try making the passenger class a subclass of the Airplane class.

dim Airplane() as clsAirplane

Public Class clsAirplane
dim mvarPassenger() as clsPassenger
{Property for Passenger}
end class

Public Class clsPassenger
dim mvarName as string
{Properties for Name}
End Class

The trick to this, in the Airplane class, remember to set the datatypes for
the Passenger property AS clsPassenger.  Also, remember that the property is
in array, so you must include an index and redim the sucker if needbe.

Setting the Passenger Property would be something like:
Airplane(1).Passenger(1).Name

It's soo much nicer than the old Type Array's, and is very easy to manage.
If ya want more info, send me an e-mail and I can help you out with more.
BTW, you can have a subClass of the SubClass, I've gone down to 45
subclasses under the Parent Class.  I got this method from a game, of all
places!

HTH
Jody W

This will compartmentalize the subclass into the Parent class.


Quote:
> Hi Guys,

> I am trying to write a VB.NET app that is real world
> modelled by have one class (the aeroplane class) that
> contains several instances of another class (the
> passenger class).  Please can someone explain
> to me how I should model with in VB.NET.  I can't
> seem to find any good help on the subject or I am
> not looking in the correct place.

> Any help is much appreciated.

> Regards,

> Jason.



Mon, 12 Sep 2005 11:32:49 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Dim obj As New Class crt Dim Obj As Class = New Class

2. derive class from protected class in base class

3. Exposing Properties collection in custom classes as many MS Classes do

4. Class raising an event from another class?

5. Class modules 97 - Refering to array within a custom class module

6. Classes within Classes

7. Pass Class reference of unkown class

8. Pass integer Value from forms Class mod to report class mod

9. newbie: private class variables are visible in class instances

10. Class 2 and Class 3 Authenticode certificates

11. Serializing a Class within a Class (Previously Structures)

12. Convert a class into another class?

 

 
Powered by phpBB® Forum Software