Example #1
0
function printMenu(MyIterator $iterator)
{
    while ($iterator->hasNext()) {
        $menuItem = $iterator->next();
        echo $menuItem->getName() . "\n";
        echo $menuItem->getPrice() . "\n";
        echo $menuItem->getDescription() . "\n";
        echo "\n";
    }
}
 private function isVegetarian($name, MyIterator $iterator)
 {
     while ($iterator->hasNext()) {
         $menuItem = $iterator->next();
         if ($menuItem->getName() == $name) {
             if ($menuItem->isVegetarian()) {
                 return TRUE;
             }
         }
     }
     return FALSE;
 }
 public function printMenu(MyIterator $iterator = NULL)
 {
     if ($iterator == NULL) {
         $menuIterator = $this->menus->iterator();
         while ($menuIterator->hasNext()) {
             $menu = $menuIterator->next();
             printMenu($menu->createIterator());
         }
     } else {
         while ($iterator->hasNext()) {
             $menuItem = $iterator->next();
             print $menuItem->getName() . ", ";
             print $menuItem->getPrice() . " -- ";
             println($menuItem->getDescription());
         }
     }
 }
 public function nextElement()
 {
     return $this->iterator->next();
 }