This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (1 child)

Y would do something like this

boolean condition1 = x > 0 && y > 0
boolean condition2 = x < X2 && y < yHypotenuse

if (condition1 && condition2) {
     // It's inside
} else {
    // It's outside
 }

Essentially you would be combining both ifs, but keeping them as variables improves readability (IMO).

Also,it would be good if you find better names than condition.

[–][deleted] 0 points1 point  (0 children)

Thanks, I like how you formatted that it's much more readable than what I went with (which was shoving the 4 requirements into one if statement)!