jeudi 21 février 2019

Wrong action taken in while loop with multiple If

Excuse me for noob question, but I can't figure out why my while loop is doesn't work as expected. The case is pretty simple: check if the checkbox is enabled, and enable/disable it. So the problem is that if both 'enable' and 'enabled' are true - the code still clicks the target, while it is not supposed to. I'm 100% sure that the inputs are correct. So the problem is supposed o be in my ugly while loop.

public void clickDisable(int index, Boolean enable)
{
    Boolean enabled = this.isCheckMarkEnabled(index);
    Boolean conditionMet = false;
    while (!conditionMet)
    {
    if (!enabled&!enable)
        {
        System.out.println("case false false");
conditionMet=true; break;}
    if (enabled & !enable);
        {
            System.out.println("case true false");
             client.click("NATIVE", enableButtons, index, 1);
             conditionMet=true;
        }
    if (enabled & enable) 
        {
        System.out.println("case true true");
            break;
        }
    if (!enabled &enable)
        {
        System.out.println("case false true");

            client.click("NATIVE", enableButtons, index, 1);
            conditionMet=true;
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire