跪求java大神帮忙,在线等答案!!!今晚就要交了!!!
答案:2 悬赏:60 手机版
解决时间 2021-02-09 05:54
- 提问者网友:鼻尖触碰
- 2021-02-08 14:32
跪求java大神帮忙,在线等答案!!!今晚就要交了!!!
最佳答案
- 五星知识达人网友:西风乍起
- 2021-02-08 15:31
下面是代码,自己亲手敲的,测试方法没有写,你可以自己写下,我仅仅具体化了一个Bird对象,就是FatherBird和SonBird,你也可以具体化其他海中或者大陆上的动物...
public abstract class Animal {
abstract void graphStand();
}
public interface AnimalRespond {
public void keepSameDistance();
public void accessBoundary();
}
public class OceanAnimal extends Animal implements AnimalRespond{
public void graphStand() {
System.out.println("这是海洋中的动物,它是由一个三角代表");
}
public void keepSameDistance() {
System.out.println("海洋动物保持距离");
}
public void accessBoundary() {
System.out.println("海洋动物到达边界,回头");
}
}
public class SkyAnimal extends Animal implements AnimalRespond {
public void graphStand() {
System.out.println("这是空中的动物,它是由一个圆代表");
}
public void keepSameDistance() {
System.out.println("空中动物保持距离");
}
public void accessBoundary() {
System.out.println("空中动物到达边界,回头");
}
}
public class MainlandAnimal extends Animal implements AnimalRespond {
public void graphStand() {
System.out.println("这是大陆中的动物,它是由一个方块代表");
}
public void keepSameDistance() {
System.out.println("大陆动物保持距离");
}
public void accessBoundary() {
System.out.println("大陆动物到达边界,回头");
}
}
public class FatherBird extends SkyAnimal {
public void graphStand() {
super.graphStand();
}
public void keepSameDistance() {
super.keepSameDistance();
}
public void accessBoundary() {
super.accessBoundary();
}
}
public class SonBird extends FatherBird{
public void graphStand() {
super.graphStand();
}
public void keepSameDistance() {
super.keepSameDistance();
}
public void accessBoundary() {
super.accessBoundary();
}
}
public class SonBird extends FatherBird{
public void graphStand() {
super.graphStand();
}
public void keepSameDistance() {
super.keepSameDistance();
}
public void accessBoundary() {
super.accessBoundary();
}
}
如果需要测试方法,也可以写写。追问真是太感谢了!不知能否帮忙写下测试方法?追答测试写出来了,我私信你了,这边装不下。。。
public abstract class Animal {
abstract void graphStand();
}
public interface AnimalRespond {
public void keepSameDistance();
public void accessBoundary();
}
public class OceanAnimal extends Animal implements AnimalRespond{
public void graphStand() {
System.out.println("这是海洋中的动物,它是由一个三角代表");
}
public void keepSameDistance() {
System.out.println("海洋动物保持距离");
}
public void accessBoundary() {
System.out.println("海洋动物到达边界,回头");
}
}
public class SkyAnimal extends Animal implements AnimalRespond {
public void graphStand() {
System.out.println("这是空中的动物,它是由一个圆代表");
}
public void keepSameDistance() {
System.out.println("空中动物保持距离");
}
public void accessBoundary() {
System.out.println("空中动物到达边界,回头");
}
}
public class MainlandAnimal extends Animal implements AnimalRespond {
public void graphStand() {
System.out.println("这是大陆中的动物,它是由一个方块代表");
}
public void keepSameDistance() {
System.out.println("大陆动物保持距离");
}
public void accessBoundary() {
System.out.println("大陆动物到达边界,回头");
}
}
public class FatherBird extends SkyAnimal {
public void graphStand() {
super.graphStand();
}
public void keepSameDistance() {
super.keepSameDistance();
}
public void accessBoundary() {
super.accessBoundary();
}
}
public class SonBird extends FatherBird{
public void graphStand() {
super.graphStand();
}
public void keepSameDistance() {
super.keepSameDistance();
}
public void accessBoundary() {
super.accessBoundary();
}
}
public class SonBird extends FatherBird{
public void graphStand() {
super.graphStand();
}
public void keepSameDistance() {
super.keepSameDistance();
}
public void accessBoundary() {
super.accessBoundary();
}
}
如果需要测试方法,也可以写写。追问真是太感谢了!不知能否帮忙写下测试方法?追答测试写出来了,我私信你了,这边装不下。。。
全部回答
- 1楼网友:摆渡翁
- 2021-02-08 16:02
来 我给你写··追问太感谢了!感激不尽!!
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯