【发布时间】:2015-09-22 13:03:45
【问题描述】:
另一个类将向这个method(x,y,z) 传递随机数。我想知道boolean 确实从我最后的if() 语句返回true,所以我可以对其进行操作。我已经在 cmets 中解释了我的逻辑。
我还是很陌生,所以我的逻辑可能是错误的。
public static String FindDate(int x, int y, int z) {
boolean istrue1 =(x >= 1 && x <= 31);
boolean istrue2 =(y >= 1 && y <= 31);
boolean istrue3 =(z >= 1 && z <= 31);
if(istrue1 ^ istrue2){
if(istrue1^istrue3){
if(istrue2^istrue3){//now knowing that no values are the same, i can find the true value.
if(istrue1||istrue2||istrue3){
// I want to store/use/print/know which bool(istrue) that evaluated to true, so I would know if it is
//x,y,z that went through the algorithm successfully.
}
} else{return "Ambiguous";}
}else{return "Ambiguous";}
}else{return "Ambiguous";}
return "true"; //I would actually end up returning the value that went through the algorithm
}
【问题讨论】:
-
返回
"true"inside 你的内部if条件。
标签: java algorithm sorting operators boolean-logic