Skip to content

Instantly share code, notes, and snippets.

@tcoupland
Created November 11, 2010 21:40
Show Gist options
  • Save tcoupland/673248 to your computer and use it in GitHub Desktop.
Save tcoupland/673248 to your computer and use it in GitHub Desktop.
WhoNeedsVisitor
SpaceShip ship = new BigSpaceShip();
LauncherSystem launcher = new LauncherSystem();
launcher.launch(ship);
class LauncherSystem{
public void launch(SpaceShip ship){
Launcher launcher = new Launcher();
launcher.launch(ship);
}
}
class Launcher{
public void launch(SpaceShip ship){
System.out.println("Got a SpaceShip");
}
public void launch(BigSpaceShip ship){
System.out.println("Got a BigSpaceShip");
}
}
class BigSpaceShip extends SpaceShip{
}
class SpaceShip{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment