The problem: 50 different commands which are typed into a command line for a program, lets say for telling a robot what to do. Some of the commands have user determined values such as travel north 5
(5 units of predetermined kind). Others are simple commands, scan area
, that have no user determined input.
In my courses, I have simply made a chain of
if(userInput == "command"){do something} else if(userInput == "anotherCommand"){do something else} else if else if else if
until all of the conditions where met, which have always been few. For the commands I'm working on now, I'm just parsing out the first word to use in the conditional and then using the other words if needed.
I've tried looking for information about this topic, but I keep getting information about how to read in user input and not about the best way of sorting through a large amount of possible user inputs.
Is it just the nature of reading in user input that the only solution is just to have a chain of if else
statements until all inputs are covered?