请教一个Adapter的问题
我看了Jdon中的《设计模式之Adapter(适配器)》
http://www.jdon.com/designpatterns/adapter.htm
这篇文章,我有一点没有看懂的地方,
文章中写到的这一小段:
现在有一个应用,需要既打方形桩,又打圆形桩.那么我们需要将这两个没有关系的类综合应用.假设RoundPeg我们没有源代码,或源代码我们不想修改,那么我们使用Adapter来实现这个应用:
public class PegAdapter extends SquarePeg{
private RoundPeg roundPeg;
public PegAdapter(RoundPeg peg)(this.roundPeg=peg;)
public void insert(String str){ roundPeg.insertIntoHolestr);}
}
在insert(String str)的方法中执行的是roundPeg.insertIntoHolestr);
这不是只打了圆形桩么?方形桩是在那里打的?
望各位明白人指点一下,先谢过大家了!