1.编写Animal的实现类Cat,重写shout方法,打印输出:"小花猫喵喵叫" 2.编写Animal的实现类Dog,重写shout方法,打印输出:"大黄狗汪汪叫" 3.编写Animal的实现类Pig,重写shout方法,打印输出:"大胖猪喊喊叫"
时间: 2023-05-27 09:05:00 浏览: 176
shout2rtp-1.32.tar.gz_rtp_shout2rtp
1. Cat类的实现:
```
public class Cat implements Animal {
@Override
public void shout() {
System.out.println("小花猫喵喵叫");
}
}
```
2. Dog类的实现:
```
public class Dog implements Animal {
@Override
public void shout() {
System.out.println("大黄狗汪汪叫");
}
}
```
3. Pig类的实现:
```
public class Pig implements Animal {
@Override
public void shout() {
System.out.println("大胖猪喊喊叫");
}
}
```
阅读全文