class AnimalDemo
{
public static void main(String[] args)
{
Cat mao = new Cat();
mao.setName("xiaohua");
mao.setAge(2);
mao.run();
mao.eat();
}
}
class Animal
{
private String name;
private int age;
public Animal(){}
public void setName(String name){
this.name = name;
}
public String getName(){
return name;
}
public void setAge(int age){
this.age = age;
}
public int getAge(){
return age;
}
public void run(){
System.out.println(this.name+"run");
}
public void eat(){
System.out.println(this.name+"eat");
}
}
class Dog extends Animal
{
public Dog(){}
public void eat(){
System.out.println("吃骨头");
}