Created
September 5, 2011 20:42
-
-
Save philmander/1195871 to your computer and use it in GitHub Desktop.
Javascript interfaces revisited 2
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
//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