package demo0;
public abstract class DongWu {
int age;
abstract void info();
}
package demo0;
public class Bird extends DongWu{
String color;
public Bird(String color,int age){
this.color = color;
super.age = age;
}
@Override
void info() {
System.out.println("我是一只"+this.color+"的鸟!");
System.out.println("今年"+super.age+"岁了!");
}
}
package demo0;
public class Fish extends DongWu{
int weight;
public Fish(int weight,int age){
this.weight = weight;
super.age = age;
}
@Override
void info() {
System.out.println("我是一只"+this.weight+"斤重的鱼!");
System.out.println("今年"+super.age+"岁了!");
}
}
package demo0;
public class Test {
public static void main(String[] args) {
DongWu bird = new Bird("黄色",4);
bird.info();
DongWu fish = new Fish(5,2);
fish.info();
}
}
