Work on Dependency Injection example.

This commit is contained in:
Ilkka Seppala 2015-05-22 23:29:50 +03:00
parent ebcf46af86
commit 8b9e829b09
4 changed files with 28 additions and 0 deletions

View File

@ -3,5 +3,7 @@ package com.iluwatar;
public class App {
public static void main( String[] args ) {
Wizard wizard = new Wizard();
wizard.smoke();
}
}

View File

@ -0,0 +1,9 @@
package com.iluwatar;
public class OldTobyTobacco implements Tobacco {
@Override
public void smoke() {
System.out.println(String.format("Smoking %s", this.getClass().getSimpleName()));
}
}

View File

@ -0,0 +1,7 @@
package com.iluwatar;
public interface Tobacco {
public void smoke();
}

View File

@ -0,0 +1,10 @@
package com.iluwatar;
public class Wizard {
private OldTobyTobacco tobacco = new OldTobyTobacco();
public void smoke() {
tobacco.smoke();
}
}