I am trying to create a data structure to implement the L-System rewrite mechanism in C ++, and I just can't find anything: (.
I need to save a string of characters (s). There are several types of characters (which are given by the LSystem alphabet). Let's say we have types "A", "B", "C". Now each type of symbol can have different parameters. For example, a character of type A will have some distance, and character B will have an angle. The character C has no parameters. The string may then look like "ABABC".
Then I need to iterate through the string and perform some actions that are also associated with each type of character. “A” can mean “draw a line of length” (distance is parameter A), B is “rotation” is an angle is “degrees,” and C is a finish.
I tried to have a Symbol class and a child for each type of symbol (SymbolA class, SymbolB class, SymbolC class), but I don’t know how to create a string. I would like to avoid typecasting, etc.
Does anyone have a similar problem or have an idea that can help me?
source share