public class MyCat6 extends MyPetTest3 {
public MyCat6(String name, int age, String color, double weight) {
super(name, age, color, weight);
}
public void speak(){
System.out.println(this.getName()+":喵喵喵");
}
public void catchMouse(){
System.out.println("不管黑猫白猫抓到老鼠就是好猫");
}
public static void main(String[] args) {
MyPetTest3 cat=new MyCat6("阿猫",3,"白色",2.1);
cat.eat("鱼");
cat.speak();
if(cat instanceof MyCat6)
((MyCat6)cat).catchMouse();
else
System.out.println("cat不是一只猫!");
}
}