@Override
public void eat(){
System.out.println("吃饭");
}
}
2.装饰者模式增强
puliuc class ManWrapper implements Person{
private Person man;
public ManWrapper(Person p){
man = p;
}
public void eat(){
System.out.println("吃饭前喝点水");
man.eat();
System.out.println("吃饭后溜溜弯");
}
}
3.使用装饰的类
public void test1(){
Man man = new Man();
ManWrapper man2 = new ManWrapper(man);
man2.eat();
}