public void IteratorTest()
        {
            PancakeHouseMenu pancakeHouseMenu = new PancakeHouseMenu();
            DinerMenu        dinerMenu        = new DinerMenu();
            CafeMenu         cafeMenu         = new CafeMenu();

            Waitress waitress = new Waitress(pancakeHouseMenu, dinerMenu, cafeMenu);

            waitress.PrintMenu();
            waitress.PrintVegetarianMenu();

            Console.WriteLine("\nCustomer asks, is the Hotdog vegetarian?");
            Console.WriteLine("Waitress says: ");
            if (waitress.IsItemVegetarian("Hotdog"))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.WriteLine("\nCustomer asks, are the Waffles vegetarian?");
            Console.WriteLine("Waitress says: ");
            if (waitress.IsItemVegetarian("Waffles"))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
        public void WaitressPrintTest()
        {
            var pancakeHouseMenu = new PancakeHouseMenu();
            var dinerMenu        = new DinerMenu();
            var waitress         = new Waitress(pancakeHouseMenu, dinerMenu);

            waitress.PrintMenu();
        }
Example #3
0
        public static void Run()
        {
            PancakeHouseMenu pancakeHouseMenu = new PancakeHouseMenu();
            DinerMenu        dinerMenu        = new DinerMenu();

            Waitress waitress = new Waitress(pancakeHouseMenu, dinerMenu);

            waitress.PrintMenu();
        }
        private static void IteratorPattern()
        {
            PancakeHouseMenu pancakeHouseMenu = new PancakeHouseMenu();
            DinerMenu        dinerMenu        = new DinerMenu();

            IteratorPattern.Waitress waitress = new IteratorPattern.Waitress(pancakeHouseMenu, dinerMenu);

            waitress.printMenu();
        }
        static void Main(string[] args)
        {
            PancakeHouseMenu pancakeHouseMenu = new PancakeHouseMenu();
            DinerMenu        dinerMenu        = new DinerMenu();

            Waitress waitress = new Waitress(pancakeHouseMenu, dinerMenu);

            waitress.PrintMenu();
        }
        static void Main(string[] args)
        {
            PancakeHouseMenu pm = new PancakeHouseMenu();
            DinerMenu        dm = new DinerMenu();

            Waitress w = new Waitress(pm, dm);

            w.PrintMenu();
        }
Example #7
0
        static void Main(string[] args)
        {
            var pancakeHouseMenu = new PancakeHouseMenu();
            var dinerMenu        = new DinerMenu();

            var waitress = new Waitress(pancakeHouseMenu, dinerMenu);

            waitress.PrintMenu();
        }
Example #8
0
        static void TryPrintMenuFromWaitress()
        {
            Console.WriteLine("\n---- Waitress ----");
            var breakfastMenu = new PancakeHouseMenu();
            var dinerMenu     = new DinerMenu();
            var cafeMenu      = new CafeMenu();

            var waitress = new Waitress(dinerMenu, breakfastMenu, cafeMenu);

            waitress.PrintMenu();
        }
Example #9
0
        public void Iterator_CollectionsDemo()
        {
            PancakeHouseMenu pancakeHouseMenu = new PancakeHouseMenu();
            DinerMenu        dinerMenu        = new DinerMenu();
            List <IMenu>     menus            = new List <IMenu>();

            menus.Add(pancakeHouseMenu);
            menus.Add(dinerMenu);
            Waitress waitress = new Waitress(menus);

            waitress.PrintMenu();
        }
Example #10
0
        static void MenuTestDriveUsingIEnumerator()
        {
            var pancakeHouseMenu = new PancakeHouseMenu();
            var dinerMenu        = new DinerMenu();
            // var cafeMenu = new CafeMenu();

            var waitress = new Waitress(new ArrayList(3)
            {
                pancakeHouseMenu, dinerMenu
            });

            waitress.PrintMenu();
        }
Example #11
0
        static void TryPrintMenuFromWaitressWithMenus()
        {
            Console.WriteLine("\n---- Waitress with menu list ----");
            var breakfastMenu = new PancakeHouseMenu();
            var dinerMenu     = new DinerMenu();
            var cafeMenu      = new CafeMenu();

            // Все хорошо, но потерялись заголовки меню
            var waitress = new WaitressWithMenus(new List <IMenu>()
            {
                breakfastMenu, dinerMenu, cafeMenu
            });

            waitress.PrintMenu();
        }
Example #12
0
        public void MenuIterator_GetIterator()
        {
            var pancakeHouseMenu = new PancakeHouseMenu();
            var dinerMenu        = new DinerMenu();

            IIterator pancakeIterator = pancakeHouseMenu.CreateIterator();
            IIterator dinerIterator   = dinerMenu.CreateIterator();

            var pancakeIteratorResult = PrintMenu(pancakeIterator);

            pancakeIteratorResult.OfType <IEnumerable>().Should().HaveCount(4);

            var dinerIteratorResult = PrintMenu(dinerIterator);

            dinerIteratorResult.OfType <IEnumerable>().Should().HaveCount(6);
        }
Example #13
0
        /// <summary>
        /// O padrão Iterator fornece uma maneira de acessar sequenacialmente os elementos de um objeto agregado sem expor sua representação subjacente.
        /// </summary>
        private static void TestIterator()
        {
            PancakeHouseMenu pancakeMenu = new PancakeHouseMenu();
            DinerMenu        dinerMenu   = new DinerMenu();

            foreach (var item in pancakeMenu)
            {
                var menuItem = (Iterator.MenuItem)item;
                Console.WriteLine(string.Format("{0},{1} -- {2}", menuItem.Name, menuItem.Price, menuItem.Description));
            }

            Console.WriteLine("---------------------------------------");
            foreach (var item in dinerMenu)
            {
                Console.WriteLine(string.Format("{0},{1} -- {2}", item.Name, item.Price, item.Description));
            }
        }
Example #14
0
        static void Main(string[] args)
        {
            //CafeMenu cafeMenu = new CafeMenu();
            //cafeMenu.hasNext();

            Menu pancakeHouseMenu = new PancakeHouseMenu();
            Menu dinerMenu        = new DinerMenu();
            Menu cafeMenu         = new CafeMenu();

            ArrayList menus = new ArrayList()
            {
                pancakeHouseMenu, dinerMenu, cafeMenu
            };

            Waitress waitress = new Waitress(menus);

            waitress.PrintMenu();
        }
        public static void Start()
        {
            var menu    = new Menu("Main", "All menu");
            var cafe    = new CafeMenu();
            var diner   = new DinerMenu();
            var pancake = new PancakeHouseMenu();
            var desert  = new DesertMenu();

            menu.Add(cafe);
            menu.Add(diner);
            menu.Add(pancake);
            cafe.Add(desert);

            var waitress = new Waitress(menu);

            waitress.PrintMenu();
            "**********************".P();
            waitress.PrintVegetarianMenu();
        }
Example #16
0
        private void Iterator_Click(object sender, RoutedEventArgs e)
        {
            MenuComponentBase pancakeMenu = new PancakeHouseMenu();
            MenuComponentBase dinerMenu   = new DinerMenu();
            MenuComponentBase cafeMenu    = new Menu("カフェメニュー", "夕食", new List <MenuComponentBase> {
                new MenuItem("パスタ", "マリナラソースのかかったスパゲティとサワードパン", true, 3.89),
            });
            MenuComponentBase dessertMenu = new Menu("デザートメニュー", "もちろんデザート!", new List <MenuComponentBase> {
                new MenuItem("アップルパイ", "バニラアイスクリームをのせたフレーク状生地のアップルパイ", true, 1.59),
            });

            dinerMenu.Add(dessertMenu);

            var waitress = new Waitress(new[] { pancakeMenu, dinerMenu, cafeMenu });

            waitress.PrintMenu();
            waitress.PrintVegetarianMenu();
            waitress.PrintValuePriceMenu();
        }
 public Waitress()
 {
     _dinerMenu= new DinerMenu();
     _pancakeHouseMenu=new PancakeHouseMenu();
 }
 public Waitress(PancadeHouseMenu menu1, DinerMenu menu2)
 {
     this.menu1 = menu1;
     this.menu2 = menu2;
 }
Example #19
0
 public Waitress(PancakeHouseMenu pancakeHouseMenu, DinerMenu dinerMenu)
 {
     _pancakeHouseMenu = pancakeHouseMenu;
     _dinerMenu        = dinerMenu;
 }
Example #20
0
 public Waitress(PancakeHouseMenu pancakeHouseMenu,
                 DinerMenu dinerMenu)
 {
     this.pancakeHouseMenu = pancakeHouseMenu;
     this.dinerMenu        = dinerMenu;
 }