import java.util.ArrayList;
public class Decorator implements Work
{
private Work work;
// 额外增加的功能被打包在这个List中
private ArrayList others = new ArrayList();
@Override
public void insert()
{
// TODO Auto-generated method stub
newMethod();
}
public Decorator()
{
}
public Decorator(Work work)
{
this.work = work;
otherMeoth("1111111111");
otherMeoth("222222222");
}
public void newMethod()
{
work.insert();
otherMeoth("33333333");
otherMeoth("4444444");
}
public void otherMeoth(String str)
{
System.out.println("=======" + str + "=================");
}
public static void main(String[] args)
{
Work w = new WorkImpl();
Work w1 = new Decorator(w);
w1.insert();
}
}
interface Work
{
public void insert();
}
class WorkImpl implements Work
{
@Override
public void insert()
{
System.out.println("方形桩插入");
}
}