Skip to content

anonymous /gist:327492515289d66308d1 secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
public class Command {
static final int CMD_LET = 0;
static final int CMD_DOC = 1;
static final int CMD_PRINT = 2;
static final int CMD_DO = 3;
static final int CMD_HISTORY = 4;
static final int CMD_END = 5;
static final int INVALID = 6;
String s;
String b;
public Command(String s){
this.s = s;
b = s.toLowerCase();
}
public int getCommand(){
if(b.substring(0,3) == "let")
return(CMD_LET);
if(b.substring(0,3) == "doc" && b.substring(0,2) != "do")
return(CMD_DOC);
if(b.substring(0,5) == "print")
return(CMD_PRINT);
if(b.substring(0,2) == "do")
return(CMD_DO);
if(b.substring(0,7) == "history")
return(CMD_HISTORY);
if(b.substring(0,3) == "end")
return(CMD_END);
else{ return(INVALID);
}
}
public String getArg(){
if(getCommand() == 0)
return(s.substring(4));
if(getCommand() == 1)
return(s.substring(4));
if(getCommand() == 2)
return(s.substring(6));
if(getCommand() == 3)
return(s.substring(3));
if(getCommand() == 4)
return(s.substring(8));
if(getCommand() == 5)
return(s.substring(4));
if(getCommand() == 6)
return("");
else{ return("");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.