设计模式-适配器模式

猫学狗叫

 

public interface Cat{

  public void meow();

}

public class Dog{

  public void Bark(){

    System.out.println("Bark...........");

  }

}

public class Adapter extends Cat implements Dog{

  public void meow(){

    super.Bark();

  }

}

public class Test{

  public static void main(String[] args){

    Cat cat = new Adapter();

    cat.meow();

  }

}

posted @ 2013-09-25 15:54  大川祥子  阅读(166)  评论(0编辑  收藏  举报