/**
* Created by asus on 2019/4/18.
*/
abstract class animalTest {
private String name;
private double weight;
public abstract void feed(int time);
public animalTest(String name, double weight) {
this.name = name;
this.weight = weight;
}
}
class lion extends animalTest{
public lion(String name, double weight) {
super(name, weight);
}
@Override
public void feed(int time) {
System.out.println("狮子每天吃肉"+time+"次。");
}
}
class panda extends animalTest {
public panda(String name, double weight) {
super(name, weight);
}
@Override
public void feed(int time) {
System.out.println("熊猫每天吃竹子"+time+"次。");
}
}
public class animal{
public static void main(String[] args) {
animalTest lion = new lion("辛巴",500);
animalTest panda = new panda("阿宝",300);
lion.feed(3);
panda.feed(4);
}
}
我可以帮你写,私聊我发给你吧