动物2

3. 编写Java应用程序,定义Animal类,此类中有动物的属性:名称 name,腿的数量legs,统计动物的数量 count;方法:设置动物腿数量的方法 void setLegs(),获得腿数量的方法 getLegs(),设置动物名称的方法 setKind(),获得动物名称的方法 getKind(),获得动物数量的方法 getCount()。定义Fish类,是Animal类的子类,统计鱼的数量

 

package
zuoye; public class ZUOYE { private String kind; private int legs,count; public String getKind() { return kind; } public void setKind(String kind) { this.kind = kind; } public int getLegs() { return legs; } public void setLegs(int legs) { this.legs = legs; } public int getCount() { return count; } public void setCount(int count) { this.count = count; } }
package zuoye;

public class ZUOYE extends Animal {
private int count;

public int getCount() {
    return count;
}

public void setCount(int count) {
    this.count = count;
}
}
package zuoye;

public class ZUOYE extends Animal {
private int count;

public int getCount() {
    return count;
}

public void setCount(int count) {
    this.count = count;
}
}

 

posted @ 2016-09-26 21:47  庚庚庚庚庚辰  阅读(132)  评论(0编辑  收藏  举报