Skip to content

Instantly share code, notes, and snippets.

@philmander
Created September 5, 2011 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philmander/1195871 to your computer and use it in GitHub Desktop.
Save philmander/1195871 to your computer and use it in GitHub Desktop.
Javascript interfaces revisited 2
//a car factory
var CarFactory = {
getTires: function() {
if(weather.raining) {
return new WetTireSet();
}
else {
return new SlickTireSet();
}
}
};
//creating the car
var redBull = new RaceCar("Red Bull");
var tires = CarFactory.getTires();
redBull.fitTires(tires);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment