设计模式---适配器模式

/** 
 * @author Rollen-Holt 设计模式之 適配器模式 
 */
  
interface window{ 
    void open(); 
    void close(); 
    void activated(); 
    void iconified(); 
} 
  
abstract class WindowAdapter{ 
    public void open(){ 
  
    } 
    public void close(){ 
  
    } 
    public void activated(){ 
          
    } 
    public void iconified(){ 
          
    } 
} 
  
class AdapterDemo extends WindowAdapter{ 
    public void open(){ 
        System.out.println("打开窗口"); 
    } 
    public void close(){ 
        System.out.println("关闭窗口"); 
    } 
} 
  
class hello{ 
    public static void main(String[] a){ 
        AdapterDemo a1=new AdapterDemo(); 
        a1.open(); 
        a1.close(); 
    } 
}

猜你喜欢

转载自jeenry119.iteye.com/blog/1387627