示例#1
0
        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();
        }
示例#2
0
 public override void VisitVegetables(Vegetables vegetables)
 {
     Console.WriteLine("I do not want to eat vegetables");
 }
示例#3
0
 public abstract void VisitVegetables(Vegetables vegetables);
示例#4
0
 public override void VisitVegetables(Vegetables vegetables)
 {
     Console.WriteLine("{0} take some {1}", this, vegetables);
     vegetables.AddHot();
 }