public abstract class AbstractRobot { private static int hitCount; protected String name; public BodyPart attack() { BodyPart attackedBodyPart = null; hitCount = hitCount + 1; if(hitCount>4)hitCount=1; if (hitCount == 1) { attackedBodyPart = BodyPart.ARM; } else if (hitCount == 2) { attackedBodyPart = BodyPart.HEAD; } else if (hitCount == 3) { attackedBodyPart = BodyPart.LEG; } else if (hitCount == 4) { hitCount = 0; attackedBodyPart = BodyPart.CHEST; } return attackedBodyPart; } public String getName() { return name; } public BodyPart defense() { BodyPart defencedBodyPart = null; hitCount = hitCount + 2; if(hitCount>4)hitCount=1; if (hitCount == 1) { defencedBodyPart = BodyPart.LEG; } else if (hitCount == 2) { defencedBodyPart = BodyPart.CHEST; } else if (hitCount == 3) { defencedBodyPart = BodyPart.ARM; } else if (hitCount == 4) { hitCount = 0; defencedBodyPart = BodyPart.HEAD; } return defencedBodyPart; } }