Hey guys I was wondering if there was any way to return a certain fraction of a bunch of booleans in java. Simply put I would like to find out if there is a way to create a method that when given four booleans if three of them are true it returns true but if less than three are true it returns false.
I know this might be hard to understand and if you don’t understand just post a comment saying so.
Hey guys I was wondering if there was any way to return a certain
Share
Weird question … anyway, here’s a possible solution for just 4 booleans:
For a more general solution, here’s a method that receives as parameters the number of booleans that need to be
truefor consideringtruethe whole expression, and a greater than zero variable number of boolean values:Call it like this, for the example in the question: