You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I have a problem with printVegetarianMenu() methos in Composite Iterator Pattern.
This is my method:
public function printVegetarianMenu()
{
$iterator = $this->allMenus->createIterator();
echo sprintf("\nVEGETARIAN MENU\n----");
while ($iterator->valid()) {
/** @var MenuComponent $menuComponent */
$menuComponent = $iterator->current();
$iterator->next();
try {
if ($menuComponent->isVegetarian()) {
$menuComponent->print();
}
} catch (\LogicException $e) {}
}
}
I do not know if it's a difference between java and PHP but my method doesn't print nothing because the while condition iterate only over menus so, obviusly the isVegetarian() method throws always an exception.
Do you have any idea about it?
The text was updated successfully, but these errors were encountered:
may be $menuComponent must be a not menuComponent class?
extender MenuItem implements isVegetarian() as getter, not thower of exception, like a parent.
Hi, I have a problem with printVegetarianMenu() methos in Composite Iterator Pattern.
This is my method:
I do not know if it's a difference between java and PHP but my method doesn't print nothing because the while condition iterate only over menus so, obviusly the isVegetarian() method throws always an exception.
Do you have any idea about it?
The text was updated successfully, but these errors were encountered: