Browse Source

上传文件至 ''

main
peisishuang 2 months ago
parent
commit
e70289921e
  1. 22
      W6-动物叫声系统.txt

22
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("狗:我会游泳!");
}
}
Loading…
Cancel
Save