Guest User

Untitled

a guest
Aug 21st, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. public Command getCommand(String string){
  2. Explore explore = new Explore();
  3.  
  4. String param;
  5. int length;
  6.  
  7. //if its the command EXPLORE
  8. if(string.trim().toUpperCase().startsWith(commandList.get(9).getName())){
  9. //find the length of the command
  10. length=string.toUpperCase().length();
  11. //get the next substring after the command Eplore (to find out the paramater of the command)
  12. param = string.substring(length);
  13. //and set it as the parameter of EXPLORE command
  14. explore.setParams(param);
  15. return commandList.get(9);
  16. }
  17.  
  18. for(int i=0;i<commandList.size();i++){
  19. if(string.trim().toUpperCase().startsWith(commandList.get(i).getName()))
  20. return commandList.get(i);
  21. }
  22. return null;
  23. }
Add Comment
Please, Sign In to add comment