Okay lets say you have a simple program which took letter a-z, and if you typed in "c" it would do something, for example "e" might add 2 random numbers, "h" displayed the word "hello", "x" displayed the time etc.
Now how i'm attempting to go around this by having 26 different methods, one for each letter and then a main body of code, which scans for the the users input then calls the appropriate method.
Now theirs obviously 100's of ways of going around this but the main two I'm thinking off is you could have 26 if's or a switch statement(Example, if(userInput.equals("a")) then call method a etc). Or another way I'm thinking off is having the methods labeled a-z and then lets say the user enters "f" instead of checking which letter it is it instead trusts the user and calls exactly the letter they've typed in.
for example:
-> User enters Y
userInput = y;
userInput(); - (which would essentially be calling y() which is a method name).
I believe there is a way to do this using "Reflection" from reading around here but I've heard to avoid premature optimization but in this case wouldn't it be the most logical thing to do?