#format java /** * AdapterPattern Example */ /** * Adaptee */ class Banner { private String string; public Banner(String string) { this.string = string; } public void showWithParen() { System.out.println("("+string+")"); } public void showWithAster() { System.out.println("*"+string+"*"); } } /** * Target */ interface Print { public abstract void printWeak(); public abstract void printStrong(); } /** * Adapter */ class PrintBanner extends Banner implements Print { public PrintBanner(String string) { super(string); } public void printWeak() { showWithParen(); } public void printStrong() { showWithAster(); } } public class AdapterBanner { public static void main(String[] args) { Print p = new PrintBanner("Hello"); p.printWeak(); p.printStrong(); } }