Exemplo n.º 1
0
 public object Next()
 {
     if (HasNext())
     {
         IIterator     iterator  = (IIterator)_stack.Peek();
         MenuComponent component = (MenuComponent)iterator.Next();
         if (component is Menu && !(iterator is CompositeIterator))
         {
             _stack.Push(component.CreateIterator());
         }
         return(component);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 2
0
        public void PrintVegetarianMenu()
        {
            IIterator iterator = _allMenus.CreateIterator();

            Console.WriteLine("\nVEGETARIAN MENU\n----");
            while (iterator.HasNext())
            {
                MenuComponent menuComponent = (MenuComponent)iterator.Next();
                try
                {
                    if (menuComponent.IsVegetarian())
                    {
                        menuComponent.Print();
                    }
                }
                catch (NotSupportedException)
                {
                }
            }
        }