下面是我的代码 Stud is player 但 if (Stud.equals("North")) 说它无法比较是否有另一种方法来比较它们?
String[] options = new String[] {"North", "South", "East", "West"};
JOptionPane.showOptionDialog(null, p + " " + Stud.distance(Comp) + " away" +
" Which way do you want to move?", "" + p + " is at " + Stud.getX() + ", " + Stud.getY() ,
JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE,
null, options, options[0]);
if (options.equals("North")){
Stud.moveNorth();
}
else if (options.equals("South")){
Stud.moveSouth();
}
else if (options.equals("West")){
Stud.moveWest();
}
else if (options.equals("East")){
Stud.moveSouth();
}