#Aggregation and Composition

21 messages · Page 1 of 1 (latest)

spark templeBOT
#

Hey, @woeful dagger!
Please remember to /close this post once your question has been answered!

trim tinsel
#

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

woeful dagger
#

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

trim tinsel
#

...... And you would know how to do it if they were not two different subclasses from different parentClasses?

woeful dagger
#

maybe then I could use the inheritance to apply

trim tinsel
#

hmm. You sure this will help in some sort of way?

woeful dagger
#

maybe not you are right

#

is this like some sort of Aggregation ?

trim tinsel
#

I always forget the difference between composition and aggregation

woeful dagger
#

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

trim tinsel
#

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

woeful dagger
#

interface?

trim tinsel
#

someFaculty.addUndergrad(someUndergrad);
someUndergrad.setFaculty(someFaculty);

woeful dagger
#

ok thanks