java之适配器模式

interface Window {
    public void open();

    public void close();

    public void activated();

    public void iconified();

    public void deiconified();
}

abstract class WindowAdapter implements Window {
    public void open() {
    };

    public void close() {
    };

    public void activated() {
    };

    public void iconified() {
    };

    public void deiconified() {
    };
}

class WindowImpl extends WindowAdapter {
    public void open() {
        System.out.println("Open the window....");
    }

    public void close() {
        System.out.println("Close the window....");
    }
}

public class AdapterDemo {
    public static void main(String[] args) {
        Window window = new WindowImpl();
        window.open();
        window.close();
    }
}

你可能感兴趣的:(适配器模式)