
while(console.hasNext()){
String?in=console.next();
if(OPERATION_EXIT.equals(in.toUpperCase())
||OPERATION_EXIT.substring(0,1).equals(in.toUpperCase())){
System.out.println("您已成功退出女神信息.");
break;
}else?if(OPERATION_GET.equals(in.toUpperCase())
||OPERATION_GET.substring(0,1).equals(in.toUpperCase())
||OPERATION_GET.equals(prenious)){
prenious=OPERATION_GET;
if(step==1){
System.out.println("請輸入您要查詢的女神[id]");
}else?if(step==2){
try?{
Goddess?g=action.get(Integer.valueOf(in));
System.out.println(g.toString());
}catch?(Exception?e)?{
e.printStackTrace();
System.out.println("您輸入的id有誤請重新輸入!");
step=0;
}
}
step++;
2016-09-16
兄弟,這個問題解決了嗎?我與你遇到相同問題了
2016-01-01
首先你的代碼有點問題
應該要在try里面加入?step = 0;
在輸出查詢人的信息之后也要把step至為1
然后你說的那個問題,你輸入的那些文字,其實是問你進入哪個功能模塊,但是因為OPERATION_GET.equals(prenious)時,就進入了你之前進入的get這個判斷里面,所以顯得貌似這個輸入很沒意義,其實也是代碼不嚴謹的問題,如果在查詢信息之后就把prenious制空就不會出現這個狀況了
2015-09-16
id是不是聲明為int,可以把Integer.valueOf(in)改成Integer.parseInt(in)看看