そのタックショッププログラムです!
public void sale() {
if (!ingredients.isEmpty()) {
printFood();
String choice = JOptionPane.showInputDialog("Enter Your choices seperatad by a # to indicate quantity");
String[] choices = choice.split(" ");
String[] ammounts = choice.split("#");
for (int i = 0; i < choices.length; i++) {
int foodPos = (Integer.parseInt(choices[i])) - 1;
int ammount = Integer.parseInt(ammounts[i+1]);
try {
foods.get(foodPos).sale(ammount);
} catch (IndexOutOfBoundsException e) {
System.out.println("Ingredient does not exsist");
}
}
}
}
http://paste.ubuntu.com/5967772/
エラーを与える
スレッド「メイン」で例外 java.lang.NumberFormatException: 入力文字列の場合: java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) で「1#3」、java.lang.Integer.parseInt(Integer.java:492) で) java.lang.Integer.parseInt(Integer.java:527) で