P.374
The main problem the folowing statement in the next() method of the CompositeIterator class:
The createIterator() returns a new CompositeIterator, and so a new Stack!
How I solved it:
1. The Menu should return just an iterator, not an CompositeIterator
2. Let the Waitress instantiate the CompositeIterator instead of asking the Menu for one.
3. The Menu should not iterate over it's children, we use an external CompositeIterator for that!
4. The root (allMenus) is not returned by the iterator. This is because we ask the allMenus for an iterator for it's children, not for the Menu itself!
5. The printMenu() method in the Waitress should also use the CompositeIterator.
Took me some time to figure this out, maybe I'm totally wrong, please test!!
[ March 30, 2006: Message edited by: Remco Bos ]
[ March 30, 2006: Message edited by: Remco Bos ]
[ March 30, 2006: Message edited by: Remco Bos ]