Monkey类、People类和主类 E。

package jicheng;

public class Monkey {
        private String s;

        public String getS() {
            return s;
        }
        public void setS(String s) {
            this.s = s;
        }
        public Monkey(String s) {
            super();
            this.s = s;            
        }
        public void speak()
        {
            System.out.println(getS()+":咿咿呀呀......");
        }
         
}
package jicheng;

public class People extends Monkey {

    public People(String s) {
        super(s);
        
    }

    public void speak()
    {
        System.out.println(getS()+":小样的,不错嘛!会说话了!");
    }
     
    public void think()
    {
        System.out.println(getS()+":别说话,认真思考!");
    }

}
package jicheng;

public class E1 {

    public static void main(String[] args) {
           Monkey hou=new Monkey("猴子");         
           hou.speak();
           People ren=new People("人");
           ren.speak();
           ren.think();
    }

}

posted @ 2016-05-23 08:58  凌零聆  阅读(377)  评论(0编辑  收藏  举报