public abstract class AbstractRobot implements Attackable,Defensable {
private static int hitCount;
public BodyPart attack() {
BodyPart attackedBodyPart = null;
hitCount = hitCount + 1;
if (hitCount == 1) {
attackedBodyPart = BodyPart.ARM;
} else if (hitCount == 2) {
attackedBodyPart = BodyPart.HEAD;
} else if (hitCount == 3) {
// hitCount = 0;
attackedBodyPart = BodyPart.LEG;
} else if (hitCount == 4){
hitCount = 0;
attackedBodyPart = BodyPart.CHEST;
}
return attackedBodyPart;
}
Пишет что Метод attack должен возвращать BodyPart.CHEST в некоторых случаях.
Не пойму в чём ошибкаpackage com.javarush.task.task13.task1328;
public class Robot extends AbstractRobot implements Attackable, Defensable {
private String name;
public Robot(String name) {
this.name = name;
}
public String getName() {
return name;
}
}