471,627 Members | 1,269 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,627 software developers and data experts.

Custom Object that has 'nested' collections

a
The problem:

I want to allow an administrator (user) to create a list of teachers, each
teacher in turn has a list of classes, each class has a list of students.

There's an article at http://aspalliance.com/721 that describes making
classes for the Student and the StudentList, but I'm wondering how to make
classes that are collections of the other classes, ie a ClassList that holds
the StudentList class and a TeacherList class that holds the ClassList class.

TeacherList-->ClassList-->StudentList-->Student

What is the approach to use to make a custom object that could handle this
nesting?

The article mentioned above has a StudentList Class that inherits from
IEnumerable and uses a Hastable to hold the Student objects that are made up
of simple data types. I tried making classes in a similar fashion for the
ClassList and StudentList collections, but I'm having casting errors, so I'm
not sure that this is the correct approach or my implementation is not
correct.

Anyone have any ideas or suggestions as to how to nest collections like
this? or another approach to accomplish the same thing? If you want to see
the code I've tried, I can post it.

Thanks,

Paul

Feb 7 '06 #1
2 1341
> The problem:

I want to allow an administrator (user) to create a list of teachers,
each teacher in turn has a list of classes, each class has a list of
students.

There's an article at http://aspalliance.com/721 that describes making
classes for the Student and the StudentList, but I'm wondering how to
make classes that are collections of the other classes, ie a ClassList
that holds the StudentList class and a TeacherList class that holds
the ClassList class.

TeacherList-->ClassList-->StudentList-->Student

What is the approach to use to make a custom object that could handle
this nesting?

The article mentioned above has a StudentList Class that inherits from
IEnumerable and uses a Hastable to hold the Student objects that are
made up of simple data types. I tried making classes in a similar
fashion for the ClassList and StudentList collections, but I'm having
casting errors, so I'm not sure that this is the correct approach or
my implementation is not correct.

Anyone have any ideas or suggestions as to how to nest collections
like this? or another approach to accomplish the same thing? If you
want to see the code I've tried, I can post it.

Thanks,

Paul


I imagine that your problem lies in the fact that what you wrote above is
false. And your probably confused. This problem has nothing to do with nesting.

A TeacherList would not hold a ClassList.

A TeacherList has 0-n Teacher objects.
A Teacher has 1 ClassList
A ClassList has 0-n Class objects.
A Class has 1 StudentList
A StudentList has 1-n Student objects.

I would start by defining the "core" objects before worrying about the collections.
Feb 7 '06 #2
a
Chris:

OK, I think I see what you mean.

I'm not familiar with the solution to this question so it's not apparent to
me how to go about it. I'll work on your suggestion.

Thanks,

Paul

-------------------------------------------------------------------------

"chris martin" wrote:
The problem:

I want to allow an administrator (user) to create a list of teachers,
each teacher in turn has a list of classes, each class has a list of
students.

There's an article at http://aspalliance.com/721 that describes making
classes for the Student and the StudentList, but I'm wondering how to
make classes that are collections of the other classes, ie a ClassList
that holds the StudentList class and a TeacherList class that holds
the ClassList class.

TeacherList-->ClassList-->StudentList-->Student

What is the approach to use to make a custom object that could handle
this nesting?

The article mentioned above has a StudentList Class that inherits from
IEnumerable and uses a Hastable to hold the Student objects that are
made up of simple data types. I tried making classes in a similar
fashion for the ClassList and StudentList collections, but I'm having
casting errors, so I'm not sure that this is the correct approach or
my implementation is not correct.

Anyone have any ideas or suggestions as to how to nest collections
like this? or another approach to accomplish the same thing? If you
want to see the code I've tried, I can post it.

Thanks,

Paul


I imagine that your problem lies in the fact that what you wrote above is
false. And your probably confused. This problem has nothing to do with nesting.

A TeacherList would not hold a ClassList.

A TeacherList has 0-n Teacher objects.
A Teacher has 1 ClassList
A ClassList has 0-n Class objects.
A Class has 1 StudentList
A StudentList has 1-n Student objects.

I would start by defining the "core" objects before worrying about the collections.

Feb 7 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Prakash C via .NET 247 | last post: by
6 posts views Thread by Scott Zabolotzky | last post: by
2 posts views Thread by Prakash C via .NET 247 | last post: by
8 posts views Thread by a | last post: by
reply views Thread by a | last post: by
9 posts views Thread by Greger | last post: by
4 posts views Thread by Usarian | last post: by
2 posts views Thread by =?Utf-8?B?Y3Nz?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.