I dont understand, every time doMove(-,-) method is called, my hitCount remains 0. So only hand as body bodypart is called. Though its static, it should retain the last changed value. But in my case every time it's becoming 0.
Could you please help with what I am missing here?
package com.codegym.task.task13.task1328;
/*
Robot wars
*/
public class Solution {
public static void main(String[] args) {
Robot amigo = new Robot("Amigo");
Robot enemy = new Robot("Enemy");
doMove(amigo, enemy);
doMove(enemy, amigo);
doMove(amigo, enemy);
doMove(enemy, amigo);
doMove(amigo, enemy);
doMove(enemy, amigo);
doMove(amigo, enemy);
doMove(enemy, amigo);
// doMove(amigo, enemy);
}
public static void doMove(AbstractRobot robotFirst, AbstractRobot robotSecond) {
BodyPart attacked = robotFirst.attack();
BodyPart defended = robotFirst.defend();
System.out.println(String.format("%s attacked %s: its %s was attacked, and its %s was defended",
robotFirst.getName(), robotSecond.getName(), attacked, defended));
}
}