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."); } } }
public void SetHandler(AbstractHandler handler) { this.handler = handler; }