I have a list of objects I must set a property based on two criteria the 2D grid looks like this:
Property 2\Property 1 B<80 80<B<100 100<B<120 B>120
A < 100 None Red Orange Orange
100 < A < 120 None Red Orange Green
120 < A < 140 None Red Green Green
140 < A None Orange Green Green
Is there a good way to loop Property 1 and Property 2 to dynamically set the object property? It is a possibility that in the future we add few criteria and I guess that doing multiple ifs isn’t a good solution. I’m trying to avoid redundant code.
Thanks
If we could convert the 2 conditions for A and B into a system with a scale of 0-3:
if A<100 -> Ascale = 0
else if A<120 -> Ascale = 1
etc.
and for B:
if B<80 -> Bscale = 0
else if B<100 -> Bscale = 1
etc.
Then we could use a 2d array for looking up the correct output response:
out = arrayname[Ascale][Bscale];
But I don’t think this saves anything over simply hard-coding it as ifs, when only the possibility of a few extra ones, I think that hard-coding is the best solution for this.