package demo1;
public class Animal {
public String name;
public int age;
public void eat() {
System.out.println(this.name +" 正在吃饭...");
}
}
package demo1;
public class Cat extends Animal {
public void mimi() {
System.out.println(this.name + " 正在咪咪叫......");
}
}
package demo1;
public class Dog extends Animal {
//public String name;
public void bark() {
System.out.println(this.name + " 正在汪汪叫.....");
}
}
package demo1;
public class Test {
public static void main(String[] args) {
Dog dog = new Dog();
dog.name = "大黄";
dog.eat();
dog.bark();
System.out.println("==========");
Cat cat = new Cat();
cat.name = "小虎";
cat.eat();
cat.mimi();
}
}