Hi Kevin --
Thanks for (yet another) response--I appreciate your help. Unfortunately, I
have to plead ignorance and say I don't really understand what you were
trying to teach me. I'm not actually making the application below, I've just
been using it as an example in my efforts to learn about OOP. So, to
simplify things, suppose we had (a) a class TStudent whose only attribute
was the student's name, and (b) a class TCourse, with two attributes to
start--one for the course's name, and one to hold a list of enrolling
students. We'll ignore all the other factors for now.
I guess I don't understand how any of the methods associated with the
courseList would work. First, I'm thinking that courseList is going to be an
object on its own, e.g., a TList. Is it correct to assume, then, that the
constructor for TCourse would need to instantiate a TList variable
courseList, and every instance of TCourse would need to be freed with a
destructor that frees the courseList TList? (We don't know ahead of time how
many TCourse objects there will be in any given session that need to be
freed!)
Second, to fill a courseList variable, wouldn't all the TStudent instances
need to be instantiated ahead of time? Would every TStudent in the school
need to be created at application startup? (How can you fill a TList with
instances of classes that don't exist yet?)
Perhaps if I start to understand these more basic points, then your helpful
message will become clearer to me -- I'm saving it :-)
Thanks again. This list is really helpful. -- Alan C.
If you want a list of students associated with each course, you can
construct it at run time
by running through all students one by one to see if they have a coursename
corresponding to the course you
are concerned with;
If you construct a Student->Course structure and a Course->Student
structure, it will be hard to keep both
alligned: it is best to construct one only and derive a reverse
relationship
list only as needed from it;
You need two 'course' object structures todefine the variables required:
tCourseAvailable and tCourseAssigned;
the tCourseAssigned object only need a variable that indicates which
tCourseAvailable instance it 'points' to (either an index number or a
string
name: you could include the student name, though this is already implicit
in
the Tstudent object that 'owns' the assigned course instance):
the tCourseAssigned object is already part of a tstudent object so no
association is necessary
(you need a studentname variable as part of the tstudent object: any
tcourse
objects are implicitly associated with this student name!!)
I think you need an objectlist of all courses available
which will have the parameters that you want to associate with each student
();
You could create a 'Faculty_list' object which contains a
'courses_available_list' object, which contains a
list of tCourseAvailable objects:
You can pass the coursename value to the student object which will add a
courseobject for that student, and which by definition is associated with
that particular student (if you have multiple students, you can create a
studentobjectlist component which contains lists of student objects, each
having its own internal list of assigned courses)
College>FacultyList->Faculty->CoursesAvailableList->CourseAvailable
StudentList->Student->CourseAssignedList->CourseAssigned
Are you using a database to store the data: if so you can use a dataset
from
the database to read in data to your Student object
and to save new or altered student data;
You can read in data using the usual Master-Detail relationships from the
relevant database tables, the structure of which would resemble the object
stuctures that we have already defined in OO terms;
The types of structures that I am currently developing are very similar,
except they also have methods for writing and reading the data to an
associated database (Object Oriented Database): its a bit advanced if you
are only learning, and database programming knowledge is required (SQL
language etc.);
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi
_________________________________________________________________
Dont just search. Find. Check out the new MSN Search!
http://search.msn.click-url.com/go/onm00200636ave/direct/01/
_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi