static void Main(string[] args) { Console.WriteLine("访问者模式:提供一个作用于某对象结构中的各元素的操作表示,它使我们可以在不改变各元素的类的前提下定义作用于这些元素的新操作。它是一种对象行为模式。"); EmployeeList ls = new EmployeeList(); Employee f1 = new FulltimeEmployee("A"); Employee f2 = new ParttimeEmployee("B"); ls.addEmployee(f1); ls.addEmployee(f2); Department dep = new FAD(); ls.accept(dep); Console.ReadKey(); }
public abstract void visit(FulltimeEmployee emp);
public override void visit(FulltimeEmployee emp) { Console.WriteLine("FA Visit 正式员工:"+emp.name); }
public override void visit(FulltimeEmployee emp) { Console.WriteLine("FA Visit 正式员工:" + emp.name); }