You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
416 B
14 lines
416 B
// Dog类,继承Animal抽象类并实现Swimmable接口
|
|
public class Dog extends Animal implements Swimmable {
|
|
// 重写makeSound方法,实现狗的叫声
|
|
@Override
|
|
public void makeSound() {
|
|
System.out.println("Dog barks: Woof! Woof!");
|
|
}
|
|
|
|
// 实现swim方法,定义狗的游泳行为
|
|
@Override
|
|
public void swim() {
|
|
System.out.println("Dog is swimming");
|
|
}
|
|
}
|