java - Find out value that returns true from if statement -algorithm -
another class going pass in random numbers method(x,y,z)
. want know boolean
returns true last if()
statement, can operations on it. have explained logic in comments.
i still new this, logic may wrong.
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 no values same, can find true value. if(istrue1||istrue2||istrue3){ // want store/use/print/know bool(istrue) evaluated true, know if //x,y,z went through algorithm successfully. } } else{return "ambiguous";} }else{return "ambiguous";} }else{return "ambiguous";} return "true"; //i end returning value went through algorithm }
you can store boolean values other type in java. i'm not sure last comment means "the value went through", if want keep track of result of particular test, don't need write like
if (a == b) { return true; } else { return false; }
in case,
return == b;
is equivalent. if expression more complicated parens idea.
return ((a == b) || c);
and instead of returning, store result , later.
bool test = ((a == b) || c); action(test);
Comments
Post a Comment