예제 #1
0
        public static void ClientCode(AbstractHandler handler)
        {
            foreach (var food in new List <string> {
                "Nut", "Banana", "Cup of coffee", "Rat"
            })
            {
                Console.WriteLine($"Client: Who wants a {food}?");

                var result = handler.Handle(food);

                if (result != null)
                {
                    Console.Write($"   {result}");
                }
                else
                {
                    Console.WriteLine($"   {food} was left untouched.");
                }
            }
        }
예제 #2
0
 public void SetHandler(AbstractHandler handler)
 {
     this.handler = handler;
 }