Java visitor pattern instead of instanceof switch
In this question it is said I can use visitor pattern instead of a bunch of instanceof s. Jmg said "If you are not free to change A, B, and C, you could apply the visitor pattern to achieve the same." As far as I understand I still have to make A, B and C support visitor (have an accept() method, for example). My problem is I have absolutely no possibility to change A, B and C. I just get the Car object from the foreign library and have to call wash() method specific for trucks, race cars and buses. I think I still need an if-else-if construction with instanceof s. Am I right? Yes, to