コード例 #1
0
ファイル: main.php プロジェクト: pearpages/patterns-in-php
function printMenu(MyIterator $iterator)
{
    while ($iterator->hasNext()) {
        $menuItem = $iterator->next();
        echo $menuItem->getName() . "\n";
        echo $menuItem->getPrice() . "\n";
        echo $menuItem->getDescription() . "\n";
        echo "\n";
    }
}
コード例 #2
0
 private function isVegetarian($name, MyIterator $iterator)
 {
     while ($iterator->hasNext()) {
         $menuItem = $iterator->next();
         if ($menuItem->getName() == $name) {
             if ($menuItem->isVegetarian()) {
                 return TRUE;
             }
         }
     }
     return FALSE;
 }
コード例 #3
0
 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());
         }
     }
 }
コード例 #4
0
 public function nextElement()
 {
     return $this->iterator->next();
 }