You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using ChainOfResponsibility.COR;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace ChainOfResponsibility
|
|
|
|
|
{
|
|
|
|
|
internal class Client
|
|
|
|
|
{
|
|
|
|
|
public static void ClientCode(AbstractHandler handler)
|
|
|
|
|
{
|
|
|
|
|
List<string> foods = new List<string>()
|
|
|
|
|
{
|
|
|
|
|
"Nut",
|
|
|
|
|
"Banana",
|
|
|
|
|
"Cup of coffee",
|
|
|
|
|
"MeatBall"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
foreach (string food in foods)
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"Client: Who wants a {food}");
|
|
|
|
|
var result = handler.Handle(food);
|
|
|
|
|
if (result == null)
|
|
|
|
|
Console.WriteLine($" {food} was left untouched");
|
|
|
|
|
else
|
|
|
|
|
Console.WriteLine($" {result}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|