public abstract class Animal {
int age;
public Animal(int age){
this.age=age;
}
public abstract void run();
public abstract void clock();
}
public class Dog extends Animal{
String color;
public Dog(int age,String color){
super(age);
this.color=color;
}
public void run(){
System.out.println("這只"+age+"歲的狗這樣跑");
}
public void clock(){
System.out.println("這只"+color+"的狗這樣叫");
}
}
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
Dog d1=new Dog(20,"藍色");
d1.run();
d1.clock();
Dog d2=new Dog(15,"紅色");
d2.run();
d2.clock();
}
}