View gist:88aa35cd461fe37cb01d
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 Main { | |
public static void main(String[] args){ | |
//Engine petrolEngine = new PetrolEngine(); | |
Engine lpg = new LPGEngine(); | |
Car car = new Car(lpg); | |
car.start(); | |
car.stop(); |
View gist:ff6be01b760ffa4e4fc2
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 Engine { | |
void turnOn(); | |
void turnOff(); | |
} |
View gist:a7827db781d96e910ddc
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 LPGEngine implements Engine { | |
@Override | |
public void turnOn() { | |
//LPG Engine turned on. | |
} | |
@Override | |
public void turnOff() { | |
//LPG Engine turned off. |
View gist:91a907fbd85f3ded4231
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 PetrolEngine implements Engine { | |
@Override | |
public void turnOn() { | |
//Petrol Engine turned on. | |
} | |
@Override | |
public void turnOff() { | |
//Petrol Engine turned off. |
View gist:bbdcff2fd27ebaac4966
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 Car { | |
private Engine engine; | |
public Car(Engine engine) { | |
this.engine = engine; | |
} | |
public void start(){ | |
engine.turnOn(); |
View gist:016d20cfffa19381046f
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 Engine { | |
void turnOn(); | |
void turnOff(); | |
} |
View gist:a52ca749d052856c7e4f
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 Car { | |
void start(); | |
void stop(); | |
} |
View gist:c90d9177b3c51d2c68f7
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
... | |
apply plugin: 'com.neenbedankt.android-apt' | |
... | |
dependencies { | |
compile fileTree(dir: 'libs', include: ['*.jar']) | |
apt 'com.google.dagger:dagger-compiler:2.0' | |
compile 'com.google.dagger:dagger:2.0' |
View gist:b2a3109f0da8bf167720
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 LPGEngine implements Engine { | |
@Override | |
public void turnOn() { | |
Log.v("DaggerExample", "LPG Engine turned on"); | |
} | |
@Override | |
public void turnOff() { | |
Log.v("DaggerExample", "LPG Engine turned off."); |
View gist:19aebc2e6ef255dc019f
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 BMWCar implements Car { | |
Engine engine; | |
@Inject | |
public BMWCar(Engine engine) { | |
this.engine = engine; | |
} | |
@Override |