有没有会用Java编写一下这个代码,求大神帮忙!

最好是图片的,谢谢了

public class Main { //入口

public static void main(String[] args) {

DPHero ez = new DPHero();
Support qinnv = new Support();
ez.setName("伊泽瑞尔");
qinnv.setName("琴女");
}
}
***
public interface Ad { //ad接口
public void physicAttack();
}
***
public interface Ap { //ap接口
public void magicAttack();
}
***

public interface Healer { //healer接口
public void heal();
}
***
public class Hero { //hero类
private String name;
private int hp;
private int armor;
private int movespeed;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getHp() {
return hp;
}

public void setHp(int hp) {
this.hp = hp;
}

public int getArmor() {
return armor;
}

public void setArmor(int armor) {
this.armor = armor;
}

public int getMovespeed() {
return movespeed;
}

public void setMovespeed(int movespeed) {
this.movespeed = movespeed;
}
}
***
public class DPHero extends Hero implements Ad, Ap { //dphero类
@Override
public void physicAttack() {
System.out.println("可以进行物理攻击");
}

@Override
public void magicAttack() {
System.out.println("可以进行魔法攻击");
}
}
***
public class Support extends Hero implements Healer { support类
@Override
public void heal() {
System.out.println("加血");
}

public void heal(Hero hero) {
System.out.println("为"+ hero.getName() +"加血");
}

public void heal(Hero hero,int hp){
System.out.println("为"+ hero.getName() + "加"+ hp +"血");
}
}追问

能否在详细的解释一下下,我这边还是有点蒙

追答

就是最基础的java继承和接口,子类继承父类的成员变量,接口声明抽象方法,一个类去实现他,然后创建实例对象使用他们的方法

温馨提示:答案为网友推荐,仅供参考
相似回答