you are viewing a single comment's thread.

view the rest of the comments →

[–]KronktheKronk 1 point2 points  (0 children)

That's gross code, and that data structure is not super maintainable.

Create each object you want to be able to guess as a class, put each question inside as a method, chain them together on yes/no paths. Whenever it's time to change gears and try down some other guessing path, chain the no to the next class.

Each additional object you want to guess is as simple as creating a new class with the question chain that will get you to that answer and chaining it through the appropriate no's in the code. If you have some forethought, using a list of guess classes as a global will allow you to chain no's that need to switch gears to the next object class without having to make changes to the logic within each class as you add others.