#Aggregation and Composition
21 messages · Page 1 of 1 (latest)
Hey, @woeful dagger!
Please remember to /close this post once your question has been answered!
Whatever assigns a UGrad to a faculty should also assign that Faculty to that UGrad.
That can be done with UGrad having a Faculty member, or by keeping a separate registry that holds a Map of UGrads to Faculties
right, I just realized I have only created a list of UGrad in Faculty, I never actually add them
I don't know how to do that cause UGRAD and Faculty are two different subclass from different parentClass
@trim tinsel
...... And you would know how to do it if they were not two different subclasses from different parentClasses?
maybe then I could use the inheritance to apply
hmm. You sure this will help in some sort of way?
I always forget the difference between composition and aggregation
what if I make a static list in Person(Department) which admits all the ungraduate student each time their instance is created. Then whenever a new faculty instance is created I created a new list then I add the static Department student into the ungrad list that's in Faculty ?
nvm this will only add 1 students or not even one
I have a method in Person, "admintStudent(Ungrad s)" which adds a new ungeradute student instance to a static list
Unfortunately this is just simple. Whenever you run into the information that a UGrad is supposed to have a faculty, you link these two together
You're probably confused about how will you run into that information, but this is the same as knowing what people exist, that information comes from somewhere, and it can be the same
how can I implement the linking process ?
interface?
someFaculty.addUndergrad(someUndergrad);
someUndergrad.setFaculty(someFaculty);
ok thanks