这是我拥有的代码,但我不得不承认我已经变得有点代码盲,并且似乎看不到问题,尽管我觉得这很容易。任何帮助将非常感激。先感谢您。
do{
System.out.println("Command:");
scan = new Scanner (System.in);
String line;
line = scan.nextLine();
String[]SplitUpText;
SplitUpText=line.split(" ");
Command = SplitUpText[0];
int param1=-1, param2=-1;
if (Command.compareTo("move")==0)
{
if (SplitUpText.length>1)
{
param1=Integer.parseInt(SplitUpText[1]);
if(SplitUpText.length>2)
{
param2=Integer.parseInt(SplitUpText[2]);
}
}g.moveTo (param1, param2);
}else if(Command.compareTo("circle")==0){
if (SplitUpText.length>1)
{
param1=Integer.parseInt(SplitUpText[1]);
}g.circle (param1);
}else if(Command.compareTo("line")==0){
if (SplitUpText.length>1)
{
param1=Integer.parseInt(SplitUpText[1]);
if(SplitUpText.length>2)
{
param2=Integer.parseInt(SplitUpText[2]);
}
}g.lineTo (param1, param2);
} else {
System.out.println("Invalid Command");
}
} while (Command.compareTo ("end")!=0);