【发布时间】:2015-03-25 20:53:06
【问题描述】:
我是 Java 新手,我不太了解 while 循环。我想说'如果你不想选择战士职业,那就回到角色选择框。
while (chooseCharacter = true){
String[] Character= {"Kitty", "Archer","Tank","Battlemage","Warrior"};
int characterSelect = JOptionPane.showOptionDialog (null, "Choose your class", "Class Selection", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, Character, "Warrior");
if(characterSelect == 4){
JOptionPane.showMessageDialog(null, "Warrior" + "\n" + "Attack 1: Slash" + "\n" + "10 Damage :: 98% Accuracy" + "\n" + "Attack 2: Spin Attack" + "\n" + "25 Damage :: 67% Accuracy");
String[] warriorChar= {"No", "Yes"};
int warrior = JOptionPane.showOptionDialog(null, "Would you like to choose Warrior as your class?", "Choose this class?", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, warriorChar, "No");
if(warrior == 0){
chooseCharacter = true;
}
if(warrior == 1){
chooseCharacter = false;
}
}
【问题讨论】:
标签: java loops while-loop