From: Ben S. <bs...@vr...> - 2002-06-17 21:45:33
|
What if you did an observer pattern? Your object that creates the 5 other objects can register itself as listeners to those 5 objects. When each of the 5 objects generates somethings that needs to be added to the queue it could fire off an event to all listeners. In this case, the listener would be the object with the queue which would handle the event and add the object to the queue. Otherwise, if each subclass has it's OWN queue, just make the queue protected in the base class and access it directly. As you can see, since the base class has the queue, I'm wondering why the other 5 objects need to derive from the base class unless each object is supposed to have its own queue. cheers, ----- Ben Scott Research Assistant VRAC bs...@ia... On Mon, 17 Jun 2002, Brown Joshua L wrote: > hello I'm still stuck on the following problem: > > If I have a class that instantiates 5 subclasses and 1 queue, and the 5 > sub-classes are supposed to push and pop elements on the queue, what is a > good model for giving the subclasses access to the queue. > > Do I need to have a constructor for each subclass that allows me to pass in > a queue - because that method really sucks. > > j > > Josh Brown > Undergraduate - Iowa State University > Research Intern - John Deere and Co > > > |