首页 > 代码库 > 设计继承树2

设计继承树2

 1 class Animalz{ 2     String name; 3     String food; 4     int hunger; 5     void makeNoise(){} 6     void eat(){} 7     void sleep(){} 8     void roam(){} 9     10 }11  class Feline extends Animalz{12      void roam(){13          System.out.println("猫科动物的活动方式");14      }15  }16  17  class Lion extends Feline{18      void makeNoise(){19          System.out.println("狮子吼");20      }21      void eat(){22          System.out.println("狮子在肉食");23      }24  }25  26  class Canine extends Animalz{27      void roam(){28          System.out.println("犬科动物的移动方式");29      }30  }31 public class Jichenshu extends Feline{32     void makeNoise(){33         System.out.println("呜呜呜。。。。");34     }35     void eat(){36         System.out.println("狼吃肉");37     }38     public static void main(String[] args){39         Lion l = new Lion();40         l.makeNoise();41         l.eat();42         43         Jichenshu wolf = new Jichenshu();44         wolf.makeNoise();45         wolf.eat();46     }47 }

技术分享

设计继承树2