编写Java应⽤程序定义Animal类,此类中有动物属性:名
称name,腿的数量leg。。。
package st;
public class Animal {
private String name;
private int legs;
private int count;
public String getKind() {
return name;
}
public void setKind(String name) {
this.name = name;
}
public int getLegs() {
return legs;
}
public void setLegs(int legs) {
this.legs = legs;
}
public int getCount() {
记住我return count;
}
public void setCount(int count) {
}
}
package st;
public class Fish extends Animal {
}
package st;
public class Tiger extends Animal {
}
package st;
public class SouthEastTiger extends Tiger {
}
package st;
public class Test02 {
public static void main(String[] args) {
Rect re=new Rect();
re.setA(20);
re.setB(30);
Circle cc=new Circle(30);
System.out.println("radius=30圆的⾯积是:"+cc.getArea());
SouthEastTiger set= new SouthEastTiger();
set.setCount(20);
System.out.println("SouthEastTiger的数量是:"+Count());
Tiger t=new Tiger();
t.setCount(15);
System.out.println("tiger的数量是:"+t.getCount());
}
}