static void Main(string[] args) { var car = new Car(); car.Accept(new CarElementPrintVisitor()); car.Accept(new CarElementDoVisitor()); Console.ReadKey(); }
static void Main(string[] args) { // adds functionality to a class // example: extention method // https://en.wikipedia.org/wiki/Visitor_pattern var vehicle = new Vehicle(); vehicle.Horn(); vehicle = new Car(); vehicle.Horn(); var car = new Car(); car.Horn(); var truck = new Truck(); truck.Horn(); Console.ReadLine(); }
public void Visit(Car car) { Console.WriteLine("visitig car"); }
public void Visit(Car car) { Console.WriteLine("starting my car"); }