static void Main(string[] args) { Coffee coffee = new Coffee(); Meat meat = new Meat(); Vegetables vegetables = new Vegetables(); VisitorA visitorA = new VisitorA(); coffee.Accept(visitorA); meat.Accept(visitorA); VisitorB visitorB = new VisitorB(); vegetables.Accept(visitorB); Console.ReadKey(); }
public override void VisitVegetables(Vegetables vegetables) { Console.WriteLine("I do not want to eat vegetables"); }
public abstract void VisitVegetables(Vegetables vegetables);
public override void VisitVegetables(Vegetables vegetables) { Console.WriteLine("{0} take some {1}", this, vegetables); vegetables.AddHot(); }