I need a simple structure to store polygon names based on sides ... so for e.g. 1 side is "monogon", 2 sides is "digon", 3 sides is "triangle" and so on (say for upto 12 sides)
What is the simplest way to store these and reuse them in the code dynamically? for e.g. if my polygonShape class has 3 as the number of sides, it should return "Triangle" as the name (which is a property declared in the class) ( I am using Obj-c). I thought of 3 options
1. enums
typedef enum {monogon = 1, digon, triangle, ...}
But then realized this is reverse of what I need. They would actually encode the numbers for me to a string. I need to obtain the names from the numbers.
2. switch-case statements - came as close alternative
3. Arrays - Then I thought may be use arrays and their indexes map to Strings
Somehow I feel I might be missing something in the "too-simple-to-be-true" solution of arrays.
Any opinions appreciated.