Robaticus gave you the correct answer, but in the comment, not in the post, so I will expand it.
We have three flags that can take each of the three states. Thus, 3 * 3 * 3 = 27 possible options.
When faced with complex if .. then logic and such a small address space, it makes no sense to try to encode all if..then at all. Instead, one three-dimensional array contains a total of 27 elements.
const int None = 0; const int Inactive = 1; const int Active = 2;
private int ParseFlag (string flag) {switch (flag) {case "N": return None; case "I": return Inactive; case "A": return Active; default throw new Exception (string.Format ("The value of the flag {0} was received, but N, I or A is expected," flag)); }}
public FlagResult Lookup (string Flag1, string Flag2, string Flag3) {return FlagData [ParseFlag (Flag1), ParseFlag (Flag2), ParseFlag (Flag3)]; }
I will let you build an array.
Loren pechtel
source share