Skip to content

Instantly share code, notes, and snippets.

@tcoupland
Created November 11, 2010 22:01
Show Gist options
  • Save tcoupland/673282 to your computer and use it in GitHub Desktop.
Save tcoupland/673282 to your computer and use it in GitHub Desktop.
public class NeedVistorPattern {
public static void main(String[] args){
SpaceShip ship = new BigSpaceShip();
SpaceShipLauncher launcher = new SpaceShipLauncher();
launcher.launch(ship);
}
private static class SpaceShipLauncher{
public void launch(SpaceShip ship){
Launcher launcher = new Launcher();
launcher.launch(ship);
}
}
private static class Launcher{
public void launch(SpaceShip ship){
System.out.println("Got a SpaceShip");
}
public void launch(BigSpaceShip ship){
System.out.println("Got a BigSpaceShip");
}
}
private static class BigSpaceShip extends SpaceShip{
}
private static class SpaceShip{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment