Skip to content

Instantly share code, notes, and snippets.

Avatar
🎧
Focusing

Mert Şimşek iammert

🎧
Focusing
View GitHub Profile
View gist:88aa35cd461fe37cb01d
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
public interface Engine {
void turnOn();
void turnOff();
}
View gist:a7827db781d96e910ddc
public class LPGEngine implements Engine {
@Override
public void turnOn() {
//LPG Engine turned on.
}
@Override
public void turnOff() {
//LPG Engine turned off.
View gist:91a907fbd85f3ded4231
public class PetrolEngine implements Engine {
@Override
public void turnOn() {
//Petrol Engine turned on.
}
@Override
public void turnOff() {
//Petrol Engine turned off.
View gist:bbdcff2fd27ebaac4966
public class Car {
private Engine engine;
public Car(Engine engine) {
this.engine = engine;
}
public void start(){
engine.turnOn();
View gist:016d20cfffa19381046f
public interface Engine {
void turnOn();
void turnOff();
}
View gist:a52ca749d052856c7e4f
public interface Car {
void start();
void stop();
}
View gist:c90d9177b3c51d2c68f7
...
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
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
public class BMWCar implements Car {
Engine engine;
@Inject
public BMWCar(Engine engine) {
this.engine = engine;
}
@Override