作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
完成我设定的选项之一后,do while 循环结束。例如,它说:在我购买并部署了一些部队后,进程已完成,退出代码为 0。
我错过了什么?!我希望它继续下去,直到人们不希望或玩家获胜为止。
do {
refresh();
System.out.println("" +
"Lobby\n\n" +
"==========\n" +
"Balance: "+balance+"\n" +
"Production Per Tick: "+production+"\n"+
"\n----------\n" +
"Options\n" +
"----------\n" +
"1. Show map\n" +
"2. Build troops\n" +
"3. Move troops\n" +
"4. Upgrade Production\n" +
"5. End turn\n");
minimenu = input.nextInt();
if (minimenu==1) {
refresh();
displayMap(map);
System.out.println("" +
"Map Legend:\n" +
"------------\n" +
"0 = not occupied\n" +
"1 = US Territory\n" +
"2 = Terrorist Territory\n");
}
else if (minimenu==2) {
int troop;
refresh();
System.out.println("" +
"Choose the troops you want to build\n" +
"-----------------------------------\n" +
"1. Special Force - 100$\n" +
"2. Tank - 500$ \n" +
"3. F-32 - 1500$ \n" +
"--->");
troop = input.nextInt();
int amount,troopCount;
System.out.print("Number of Special Forces you want: ");
troopCount = input.nextInt();
amount = troopCount*100;
System.out.println("\nTotal: "+amount+"$\n" +
"Type 1 to conform: \n");
if (input.nextInt() ==1)
balance = balance-amount;
int X,Y;
do {
System.out.print("" +
"where do you want to deploy the troops? (Must deploy on own land!)\n" +
"Enter Y coordinate: ");
Y = input.nextInt();
System.out.println("\nEnter X Coordinate");
X = input.nextInt();
System.out.println(map[Y][X]+"This One"); //test code
if (varifyDeployment(map[Y][X])) {
if (troop==1) {
US_SpecialForce[Y][X] += troopCount;
System.out.println("Success!");
}
else if (troop ==2) {
US_Tank[Y][X] += troopCount;
System.out.println("Success!");
}
else if (troop == 3) {
US_Air[Y][X] += troopCount;
System.out.println("Success!");
}
}
else
System.out.println("Incorrect location, Try Again");
}while (!varifyDeployment(map[Y][X]));
displayMap(US_SpecialForce); //test code
}
}while (minimenu==5);
谢谢
最佳答案
看来你的逻辑不正确。您的菜单选项#5
"5. End turn\n"
但是你的 do-while 循环条件是
}while (minimenu==5);
只有当 minimenu
为 5 时,才会继续循环。我认为您希望不等于 5,因此如果不是 5
,循环就会继续,并且它会如果是 5
则结束。
}while (minimenu != 5);
关于java - Action 后循环中断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20984532/
安装并修复我的 VS2015 实例后,我仍然无法让智能感知(服务器端)在我的 MVC View 中工作。当我在 session 中第一次打开 .cshtml 文件并找到 Activitylog 文件时
我是一名优秀的程序员,十分优秀!