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");
            }
        }
Ejemplo n.º 2
0
        public void TestWaitressPrintMenu()
        {
            StringBuilder printMenuOutput = new StringBuilder();

            PancakeHouseMenu pancakeHouseMenu = new PancakeHouseMenu();
            DinnerMenu       dinnerMenu       = new DinnerMenu();
            CafeMenu         cafeMenu         = new CafeMenu();

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

            printMenuOutput.Append("MENU\n");
            printMenuOutput.Append("----\n");
            printMenuOutput.Append("BREAKFAST\n");
            printMenuOutput.Append("K&B's Pancake Breakfast, 2.99 -- Pancakes with scrambled eggs, and toast\n");
            printMenuOutput.Append("Regular Pancake Breakfast, 2.99 -- Pancakes with fried eggs, and sausage\n");
            printMenuOutput.Append("Blueberry Pancakes, 3.49 -- Pancakes made with fresh blueberries\n");
            printMenuOutput.Append("Waffles, 3.59 -- Waffles, with your choice of blueberries or strawberries\n");
            printMenuOutput.Append("\n");
            printMenuOutput.Append("LUNCH\n");
            printMenuOutput.Append("Vegetarian BLT, 2.99 -- (Fakin') Bacon with lettuce & tomato on whole wheat\n");
            printMenuOutput.Append("BLT, 2.99 -- Bacon with lettuce & tomato on whole wheat\n");
            printMenuOutput.Append("Soup of the day, 3.29 -- Soup of the day, with a side of potato salad\n");
            printMenuOutput.Append("Hotdog, 3.05 -- A hot dog with saurkraut, relish, onions, topped with cheese\n");
            printMenuOutput.Append("Steamed Veggies and Brown Rice, 3.99 -- Steamed vegetables over brown rice\n");
            printMenuOutput.Append("Pasta, 3.89 -- Spaghetti with Marina Sauce and a slice of sourdough bread\n");
            printMenuOutput.Append("\nDinner\n");
            printMenuOutput.Append("Veggie Burger and Air Fries, 3.99 -- Veggie burger on a whole wheat bun, lettuce, tomato, and fries\n");
            printMenuOutput.Append("Soup of the Day, 3.69 -- A cup of the soup of the day, with a side salad\n");
            printMenuOutput.Append("Burrito, 4.29 -- A large burrito, with whole pinto beans, salsa, guacamole\n");

            Assert.AreEqual(printMenuOutput.ToString(), waitress.PrintMenu());
        }
Ejemplo n.º 3
0
        static void Iterator()
        {
            IMenu    pancakeHouseMenu = new PancakeHouseMenu();
            IMenu    dinnerMenu       = new DinnerMenu();
            Waitress waitress         = new Waitress(pancakeHouseMenu, dinnerMenu);

            waitress.PrintMenu();
        }
Ejemplo n.º 4
0
        public void WaitressPrintTest()
        {
            var pancakeHouseMenu = new PancakeHouseMenu();
            var dinerMenu        = new DinerMenu();
            var waitress         = new Waitress(pancakeHouseMenu, dinerMenu);

            waitress.PrintMenu();
        }
Ejemplo n.º 5
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();
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            var pancakeHouseMenu = new PancakeHouseMenu();
            var dinerMenu        = new DinerMenu();

            var waitress = new Waitress(pancakeHouseMenu, dinerMenu);

            waitress.PrintMenu();
        }
        static void Main(string[] args)
        {
            PancakeHouseMenu pancakeHouseMenu = new PancakeHouseMenu();
            DinnerMenu       dinnerMenu       = new DinnerMenu();

            Waitress waitress = new Waitress(new List <IMenu> {
                pancakeHouseMenu, dinnerMenu
            });

            waitress.PrintMenu();
        }
Ejemplo n.º 11
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();
        }
Ejemplo n.º 12
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();
        }
Ejemplo n.º 13
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();
        }
Ejemplo n.º 14
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();
        }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
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));
            }
        }
Ejemplo n.º 17
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();
        }
Ejemplo n.º 19
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();
        }
Ejemplo n.º 20
0
 public Waitress(PancakeHouseMenu pancakeHouseMenu, DinnerMenu dinnerMenu)
 {
     _pancakeHouseMenu = pancakeHouseMenu;
     _dinnerMenu       = dinnerMenu;
 }
Ejemplo n.º 21
0
 public Waitress(PancakeHouseMenu pancakeHouseMenu,
                 DinerMenu dinerMenu)
 {
     this.pancakeHouseMenu = pancakeHouseMenu;
     this.dinerMenu        = dinerMenu;
 }
Ejemplo n.º 22
0
 public WaitressClient(PancakeHouseMenu packageHouseMenu, DinnerMenu dinnerMenu)
 {
     this.packageHouseMenu = packageHouseMenu;
     this.dinnerMenu = dinnerMenu;
 }
 public PancakeHouseIterator(PancakeHouseMenu pancakeHouseMenu)
 {
     _pancakeHouseMenu = pancakeHouseMenu;
 }
Ejemplo n.º 24
0
 public Waitress()
 {
     _dinerMenu= new DinerMenu();
     _pancakeHouseMenu=new PancakeHouseMenu();
 }