R
RSH
Hi,
I am working on some general OOP constructs and I was wondering if I could
get some guidance.
I have an instance where I have a Base Abstract Class, and 4 Derived
classes. I now need to make a list class that will store the objects. My
question is how do I go about creating the list class...I am assuming it
should be a standalone class that uses an arraylist to store the objects.
If I go that route how do I instantiate the objects so they get added to the
list of objects, and how do I know what type they are when iterating through
the list of objects? Or am I way off base (Pun Intended)?
public partial class Form1 : Form
{
private Child1 c1 = new Child1();
private ChildListClass clc1 = new ChildListClass();
private clc1.add(c1); << is this the correct implementation? Or do I
want to somehow make this part of the Base class and access it through a
static arraylist?
}
public Abstract Class BaseClass
{
}
public Sealed Class Child1
{
}
public Sealed Class Child2
{
}
public Class ChildListClass
{
}
Thanks!
Ron
I am working on some general OOP constructs and I was wondering if I could
get some guidance.
I have an instance where I have a Base Abstract Class, and 4 Derived
classes. I now need to make a list class that will store the objects. My
question is how do I go about creating the list class...I am assuming it
should be a standalone class that uses an arraylist to store the objects.
If I go that route how do I instantiate the objects so they get added to the
list of objects, and how do I know what type they are when iterating through
the list of objects? Or am I way off base (Pun Intended)?
public partial class Form1 : Form
{
private Child1 c1 = new Child1();
private ChildListClass clc1 = new ChildListClass();
private clc1.add(c1); << is this the correct implementation? Or do I
want to somehow make this part of the Base class and access it through a
static arraylist?
}
public Abstract Class BaseClass
{
}
public Sealed Class Child1
{
}
public Sealed Class Child2
{
}
public Class ChildListClass
{
}
Thanks!
Ron