Пример #1
0
        public static void ClientCode(BaseHandler handler)
        {
            foreach (var f in food)
            {
                Console.WriteLine($"Who wants a {f}?");

                var result = handler.Handle(f);

                if (result != null)
                {
                    Console.WriteLine("\t" + result);
                }
                else
                {
                    Console.WriteLine("\t No1");
                }
            }
        }
Пример #2
0
        public static void ClientCode(BaseHandler handler)
        {
            var setOfFood = new List <string> {
                "Nut", "Banana", "Cup of coffee"
            };

            foreach (var food in setOfFood)
            {
                Console.WriteLine($"Client: Who wants a {food}?");

                var result = handler.Handle(food);

                if (result != null)
                {
                    Console.WriteLine($"    {result}");
                }
                else
                {
                    Console.WriteLine($"    {food} was left untouched");
                }
            }
        }