package com.hanqi.test; 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) { this.count = count; } }
package com.hanqi.test; public class Fish extends Animal { }
package com.hanqi.test; public class Tiger extends Animal { }
package com.hanqi.test; public class SouthEastTiger extends Tiger { }
package com.hanqi.test; public class Test02 { public static void main(String[] args) { Rect re=new Rect(); re.setA(20); re.setB(30); re.getArea(); Circle cc=new Circle(30); System.out.println("radius=30圆 的面积是:"+cc.getArea()); SouthEastTiger set= new SouthEastTiger(); set.setCount(20); System.out.println("SouthEastTiger的数量是:"+set.getCount()); Tiger t=new Tiger(); t.setCount(15); System.out.println("tiger的数量是:"+t.getCount()); } }