diff --git a/src/learn/simple_adapter/Adaptee.java b/src/learn/simple_adapter/Adaptee.java new file mode 100644 index 0000000..4c53245 --- /dev/null +++ b/src/learn/simple_adapter/Adaptee.java @@ -0,0 +1,7 @@ +package learn.simple_adapter; + +public class Adaptee { + public void specificRequest() { + System.out.println("Specific Request"); + } +} diff --git a/src/learn/simple_adapter/Adapter.java b/src/learn/simple_adapter/Adapter.java new file mode 100644 index 0000000..bed7989 --- /dev/null +++ b/src/learn/simple_adapter/Adapter.java @@ -0,0 +1,14 @@ +package learn.simple_adapter; + +public class Adapter implements Target { + private Adaptee adaptee; + + public Adapter(Adaptee adaptee) { + this.adaptee = adaptee; + } + + @Override + public void request() { + adaptee.specificRequest(); + } +} diff --git a/src/learn/simple_adapter/Main.java b/src/learn/simple_adapter/Main.java new file mode 100644 index 0000000..0074e64 --- /dev/null +++ b/src/learn/simple_adapter/Main.java @@ -0,0 +1,9 @@ +package learn.simple_adapter; + +public class Main { + public static void main(String[] args) { + Adaptee adaptee = new Adaptee(); + Target adapter = new Adapter(adaptee); + adapter.request(); + } +} diff --git a/src/learn/simple_adapter/Target.java b/src/learn/simple_adapter/Target.java new file mode 100644 index 0000000..9931439 --- /dev/null +++ b/src/learn/simple_adapter/Target.java @@ -0,0 +1,5 @@ +package learn.simple_adapter; + +public interface Target { + void request(); +}