Exemplo n.º 1
0
 public override void HandleFood(Food food)
 {
     if (food.Name.Contains("Soup"))
     {
         Console.WriteLine("Me: I like Soup. It went well.");
     }
     base.HandleFood(food);
 }
Exemplo n.º 2
0
 public virtual void HandleFood(Food food)
 {
     // If I cannot handle other food, passing it to my successor
     if (CafeVisitor != null)
     {
         CafeVisitor.HandleFood(food);
     }
 }
Exemplo n.º 3
0
 public override void HandleFood(Food food)
 {
     if (food.Name == "Cappuccino")
     {
         Console.WriteLine("GirlFriend: My lovely cappuccino!!!");
         return;
     }
     base.HandleFood(food);
 }
Exemplo n.º 4
0
 public override void HandleFood(Food food)
 {
     if (food.Ingradients.Contains("Meat"))
     {
         Console.WriteLine("BestFriend: I just ate {0}. It was testy.", food.Name);
         return;
     }
     if (food.Ingradients.Contains("Coffee") && CoffeeContainingFood.Count < 1)
     {
         CoffeeContainingFood.Add(food);
         Console.WriteLine("BestFriend: I have to take something with coffee. {0} looks fine.", food.Name);
         return;
     }
     base.HandleFood(food);
 }
Exemplo n.º 5
0
        public static void Run()
        {
            var cappuccino1 = new Food("Cappuccino", new List<string> { "Coffee", "Milk", "Sugar" });
            var cappuccino2 = new Food("Cappuccino", new List<string> { "Coffee", "Milk" });
            var soup1 = new Food("Soup with meat", new List<string> { "Meat", "Water", "Potato" });
            var soup2 = new Food("Soup with potato", new List<string> { "Water", "Potato" });
            var meat = new Food("Meat", new List<string> { "Meat" });

            var girlFriend = new GirlFriend(null);
            var me = new Me(girlFriend);
            var bestFriend = new BestFriend(me);

            bestFriend.HandleFood(cappuccino1);
            bestFriend.HandleFood(cappuccino2);
            bestFriend.HandleFood(soup1);
            bestFriend.HandleFood(soup2);
            bestFriend.HandleFood(meat);
        }