This file contains hidden or 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(); | |
} |
This file contains hidden or 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. |
This file contains hidden or 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. |
This file contains hidden or 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(); | |
Car car = new Car(petrolEngine); | |
car.start(); | |
car.stop(); | |
} |
This file contains hidden or 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(); |
This file contains hidden or 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
// Top-level build file where you can add configuration options common to all sub-projects/modules. | |
buildscript { | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
classpath 'com.android.tools.build:gradle:1.2.3' | |
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4' |
This file contains hidden or 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' |
This file contains hidden or 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(); | |
} |
This file contains hidden or 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(); | |
} |
This file contains hidden or 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."); |