This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Planet { | |
void accept(Explorer explorer); | |
} | |
public class Mercury implements Planet { | |
@Override | |
public void accept(Explorer explorer) { | |
explorer.visit(this); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Planet mars = new Mars() | |
Planet saturn = new Saturn(); | |
Planet mercury = new Mercury() | |
Explorer explorer = new LifeExplorer(); | |
List<Planet> planetsToBeVisited = new ArrayList<>(); | |
planetsToBeVisited.add(mars); | |
planetsToBeVisited.add(saturn); | |
planetsToBeVisited.add(mercury); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Planet{ | |
public void accept(Explorer explorer); | |
} | |
public class Mercury implements Planet { | |
@Override | |
public void accept(Explorer explorer)) { | |
explorer.visit(this); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Planet{ | |
public void accept(Explorer explorer); | |
} | |
public class Mercury implements Planet { | |
@Override | |
public void accept(Explorer explorer)) { | |
explorer.visit(this); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LandscapeExplorer implements Explorer { | |
@Override | |
public void visit(Mercury mercury) { | |
System.out.println("Adjusting camera to Mercury atmosphere... taking picture of Mercury"); | |
} | |
@Override | |
public void visit(Mars mars) { | |
System.out.println("Adjusting camera to Mars atmosphere ... taking picture of Mars"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Explorer { | |
void visit(Mercury mercury); | |
void visit(Mars mars); | |
void visit(Saturn saturn); | |
default void visit(Planet planet) { | |
System.out.println("Landed on an unknown planet..."); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Planet mars = new Mars() | |
Planet saturn = new Saturn(); | |
Planet mercury = new Mercury() | |
Explorer explorer = new LifeExplorer(); | |
List<Planet> planetsToBeVisited = new ArrayList<>(); | |
planetsToBeVisited.add(mars); | |
planetsToBeVisited.add(saturn); | |
planetsToBeVisited.add(mercury); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Planet { } | |
public class Mercury implements Planet { } | |
public class Mars implements Planet { } | |
public class Saturn implements Planet { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* IE 5.5+, Firefox, Opera, Chrome, Safari XHR object | |
* | |
* @param string url | |
* @param object callback | |
* @param mixed data | |
* @param null x | |
*/ | |
function ajax(url, callback, data, x) { | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |