在关卡最后的问答游戏中,我必须检查一些条件,其中有 4 个。在游戏过程中,我将+1添加到一个整数变量,4个变量。在关卡结束时,我将这些值与另一个整数 activeButtonsTotal 相加。我将 4 个 boolean 值设置为 true 或 false。因此,我需要检查 2 个条件四次:如果我的 boolean 值为 false,并且我的 activeButtonsTotal 是否等于 16,以及是否将我的按钮之一设置为“启用”,对于下一个 boolean 值和 activeButtonsTotal 也是如此,以及如此4次。我需要把这 4 个都经历一遍。我尝试使用 if 语句和 else if 但没有成功。
boolean columnACorrecct, columnBCorrect, columnCCorrect, columnDCorrect;
activeButtonsTotal = activeButtonsA+activeButtonsB+activeButtonsC+activeButtonsD;
if((columnACorrect=false) && (activeButtonsTotal==16)){
columnA.setEnabled(true);
}
if((columnBCorrect=false) && (activeButtonsTotal==16)){
columnB.setEnabled(true);
}
if((columnCCorrect=false) && (activeButtonsTotal==16)){
columnC.setEnabled(true);
}
if((columnDCorrect=false) && (activeButtonsTotal==16)){
columnD.setEnabled(true);
}
最佳答案
我不确定我是否遵循您的所有逻辑,但您的“if”语句都缺少等号。您说您必须比较您的 boolean 值是否为假以及数字,但您在条件内分配了“False”。你需要“==”。
我会这样做:
if(activeButtonsTotal==16)
{
columnA.setEnabled(!columnACorrect);
columnB.setEnabled(!columnBCorrect);
columnC.setEnabled(!columnCCorrect);
columnD.setEnabled(!columnDCorrect);
}
关于java - 如何查询多条报表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25344038/