I have to model this table:
--------------------------------------
| range | X<10 | 10<X<30 | 30<X<50 |
|--------|---------------------------|
| Y<5 | HIGH | MIDDLE | LOW |
|------------------------------------|
| 5<Y<10 | MIDDLE| LOW | HIGH |
|____________________________________|
So I have to model it in a method that takes 2 parameters (X and Y) and return the correct value based on this table.
I thought on a map based implementation, but maybe this is not the best way.
How would you model it?
Kind regards
Massimo
How about two maps?
The
Rangewill hold 2 integers (lower and upper bounds) , you will need to implementequals()andhashcode()in order for theRangeto fit the `Map’ nature.So, the first
Mapwill filter byXand the 2ndMapfill get the value (HIGH, LOW, etc)