How to make a boolean variable turn true when called in a main method //Java

Random random = new Random();
double rand = random.nextDouble();
boolean att = false;
public double attack(double AttackDam, double Health, double Stamina, double BlockChance)
{
            att = true;
    do
    {
        if(BlockChance == 0.0)
        {
            Health = Health - AttackDam;
        }
        else
        {
            AttackDam = AttackDam - BlockChance;
            Health = Health - AttackDam%BlockChance;
            Stamina = Stamina - AttackDam%BlockChance;
        }

    }while(att == true);
    return Health;
}

But where are you setting att to false, to break free from the do...while loop?

Leave a Comment