Work on Dependency Injection example.
This commit is contained in:
parent
ebcf46af86
commit
8b9e829b09
@ -3,5 +3,7 @@ package com.iluwatar;
|
||||
public class App {
|
||||
|
||||
public static void main( String[] args ) {
|
||||
Wizard wizard = new Wizard();
|
||||
wizard.smoke();
|
||||
}
|
||||
}
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.iluwatar;
|
||||
|
||||
public interface Tobacco {
|
||||
|
||||
public void smoke();
|
||||
|
||||
}
|
10
dependency-injection/src/main/java/com/iluwatar/Wizard.java
Normal file
10
dependency-injection/src/main/java/com/iluwatar/Wizard.java
Normal file
@ -0,0 +1,10 @@
|
||||
package com.iluwatar;
|
||||
|
||||
public class Wizard {
|
||||
|
||||
private OldTobyTobacco tobacco = new OldTobyTobacco();
|
||||
|
||||
public void smoke() {
|
||||
tobacco.smoke();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user