diff --git a/W6-动物叫声系统.txt b/W6-动物叫声系统.txt new file mode 100644 index 0000000..0055a97 --- /dev/null +++ b/W6-动物叫声系统.txt @@ -0,0 +1,22 @@ +public abstract class AinmalSound { + public abstract void makeSound(); +} +interface Swimmable{ + void swim(); +} +class Cat extends AnimalSound { + @Override + public void makeSound() { + System.out.println("猫:喵喵喵!"); + } +} +class Dog extends AnimalSound implements Swimmable { + @Override + public void makeSound() { + System.out.println("狗:汪汪汪!"); + } + @Override + public void swim() { + System.out.println("狗:我会游泳!"); + } +} \ No newline at end of file