The new body part must be added to the logic for the attack and defend methods in the AbstractRobot class.
1. Familiarize yourself with the code.
2. Accept your fate and keep trying to understand the code.
3. ...
4. Rejoice that you've figured it out.
5. Adapt the code to the following new architecture and add new logic:
5.1. Make the AbstractRobot class abstract. Then move the attack and defend logic from the Robot class to the AbstractRobot class.
5.2. Edit the Robot class to utilize the AbstractRobot class.
5.3. Extend the BodyPart class with a new body part: BodyPart.CHEST.
5.4. Add the new body part to the implementation of the CanAttack and CanDefend interfaces (in the AbstractRobot class).
Requirements:
The AbstractRobot class must be abstract.
The AbstractRobot class must implement the CanAttack and CanDefend interfaces.
The Robot class must inherit the AbstractRobot class.
The logic defining the how a Robot behaves must be in the AbstractRobot class.
The BodyPart class must have and initialize a final static BodyPart variable called CHEST.
The new body part must be added to the logic for the attack and defend methods in the AbstractRobot class.
Abstract robot class, both line 16 and line 33 have: else if (hitCount == 4)
if the last hit count was 3 and you increase it by two (as in the defense), you will be left with a hit count of 5 and none of your if statements will be true thereafter. This means that null will be returned as the body point from that point on.
Change both of these to just else and not if else (logic).