装饰练习

public class zhuangshiDemo
{
    public static void main(String[] args)
    {

            new superperson(new person()).eat();

    }
}
class person
{
    public void eat()
    {
        System.out.println("吃家常饭");
    }
}
class superperson
{
    private person p;
    public  superperson(person p)
    {
        this.p=p;
    }
    public void eat()
    {
        System.out.print("喝酒");
        System.out.println("he cha");
        p.eat();
        
    }
}

posted on 2012-11-01 22:41  蝌蚪的精神  阅读(112)  评论(0编辑  收藏  举报

导航