1 changed files with 22 additions and 0 deletions
@ -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…
Reference in new issue