We have a c++ project where we shall program a simple command line based RPG game. The game shall be controlled through word based commands. All commands are at maximum three words long. To begin with, we have used chains of else-if conditions to determine which command to invoke. However, this solution becomes error prone and the source code becomes unobservable as the number of possible commands grows.
What I wonder is how this standard problem is solved in other applications? I guess there must a standard pattern for this problem, but I have not been able to figure out which it is.
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire