标签:
class Barrel
{
public void getOilFromBarrel()
{
System.out.println("get oil from Barrel ok");
}
}
class Funnel implements Bottle
{
private Barrel aBarrel=new Barrel();
public void getOil()
{
aBarrel.getOilFromBarrel();
}
}
interface Bottle
{
void getOil();
}
public class AdapterPatternTest
{
public static void main(String[] args)
{
Bottle aBottle=new Funnel();
aBottle.getOil();
}
}
/////////////////////
输出结果:
get oil from Barrel ok
java中23种设计模式之7-适配器模式(adapter pattern)
标签:
原文地址:http://www.cnblogs.com/wudymand/p/4378996.html