How to simply this logic/code?
- by Tattat
I want to write an apps that accepts user command. The user command is used in this format:
command -parameter
For example, the app can have "Copy", "Paste", "Delete" command
I am thinking the program should work like this :
public static void main(String args[]){
if(args[0].equalsIgnoreCase("COPY")){
//handle the copy command
} else if(args[0].equalsIgnoreCase("PASTE")){
//handle the copy command
}/**
code skipped
**/
}
So, it works, but I think it will become more and more complex when I have more command in my program, also, it is different to read. Any ideas to simply the logic?