I have 5 boolean variables a,b,c,d and e. So for each different combination of true and false of each variable there is a different print statement.
Say for example:
a b c d e — Print Statements
T T T T T — Print All trues
T T T T F — Print Some Text
T T T F F — Print Some other text
……..
There could be 32 different possible combinations. I’m writing a java code. So the question is for every condition there should be a different statement printed out. So what could be the best possible solution to handle this instead of the regular if statements which makes the code more confusing and unmanageable?
One option would be to basically build a bitmask:
… where
statementsis an array of length 32. So in your case,statements[31]would be “All trues”, andstatements[30]would be “Some Text” etc.