I have to create reports based on the user input. User answer a question, and then depending on the answer I go left or right in a treelike structure, and ask a new question. Some nodes will have the same question, but different children. I am not sure what would be the best way to do it in terms of code readability?
I would like to avoid huge control structure, as it would be extremely unreadable, like this:
if() {
if() {
if() {
if() {
...
}
}
else {
if() {
...
}
}
}
else {
...
}
}
else {
if() {
if() {
if() {
...
}
}
else {
if () {
...
}
}
}
}
Is there some better way to deal with it? Here is an image of how my tree looks like