java - Do I have this written properly? .equals AND !.equals if statement -
fixed. statement evaluate way wanted had write way:
public static boolean pushcard(string s1, string s2) { boolean result = false; if ((s1.equals("fire") || s1.equals("wind") || s1.equals("water"))) if (!s2.equals("fire") && (!s2.equals("water") && (!s2.equals("fire")))) result = true; return result; } //end push card method
i can not tell if comparison causing issues. using == instead of .equals learned wrong way write it. help!
public static boolean pushcard(string s1, string s2) { boolean result = false; if ((s1.equals("fire") || s1.equals("wind") || s1.equals("water"))) if (!s2.equals("fire") || (!s2.equals("water") || (!s2.equals("fire")))) result = true; return result; } //end push card method
syntactically, code compile fine, , way use .equals()
method compare strings correct. use of !
operator correct.
there no guarantee code not have logical errors though.
Comments
Post a Comment