public class A {
public static void main(String[] args) {
JumpCat c =new JumpCat("加菲",12);
c.jump();
c.eat();
}
}
abstract class Animal {
private String name;
private int age;
public Animal (){
}
public Animal(String name,int age) {
this.name=name;
this.age=age;
}
public void setAge(int age) {
this.age=age;
}
public int getAge() {
return age;
}
public void setName() {
this.name=name;
}
public String getName() {
return name;
}
public abstract void eat();
}
class Cat extends Animal{
public Cat(){}
public Cat(String name,int age) {
super(name,age);
}
public void eat() {
System.out.println("猫吃鱼");
}
}
interface jumping {
abstract public void jump();
}
class JumpCat extends Cat implements jumping {
public JumpCat(){}
public JumpCat(String name,int age) {
super(name,age);
}
public void jump() {
System.out.println("猫跳高");
}
}
JAVA猫狗案例跳高
2021/12/1 17:11:56