어젯밤에이 프로그램을 게시했는데 여전히 OOP 파다완 인 이유는 내 방법에있는 나머지 if-else
이 실행되지 않습니다. 나는 de-bugger를 돌 봤고, 내 if
을 보았고 if-else
을 보지 않았다. 결과적으로 내 출력이 변경되지 않습니다. 여기에 언급 된 방법이 있습니다 :나머지 if-else 분기가 실행되지 않는 이유는 무엇입니까?
public String getBadge(int requestedStat) {
String badgeOutput = "";
if (requestedStat >= 0 && requestedStat <=9) {
for (int i = 0; i < badgeRanks.length-5; i++) {
if (gamerActions[requestedStat] >= badgePoints[requestedStat][i]
&& gamerActions[requestedStat] < badgePoints[requestedStat][i + 1]) {
badgeOutput = badgeTitles[requestedStat] + badgeRanks[i];
} else if (gamerActions[requestedStat] >= badgePoints[requestedStat][i + 1]
&& gamerActions[requestedStat] < badgePoints[requestedStat][i + 2]) {
badgeOutput = badgeTitles[requestedStat] + badgeRanks[i + 1];
} else if (gamerActions[requestedStat] >= badgePoints[requestedStat][i + 2]
&& gamerActions[requestedStat] < badgePoints[requestedStat][i + 3]) {
badgeOutput = badgeTitles[requestedStat] + badgeRanks[i+2];
} else if (gamerActions[requestedStat] >= badgePoints[requestedStat][i + 3]
&& gamerActions[requestedStat] < badgePoints[requestedStat][i + 4]) {
badgeOutput = badgeTitles[requestedStat] + badgeRanks[i+3];
} else if (gamerActions[requestedStat] >= badgePoints[requestedStat][i + 4]
&& gamerActions[requestedStat] < badgePoints[requestedStat][i + 5]) {
badgeOutput = badgeTitles[requestedStat] + badgeRanks[i+4];
} else {
badgeOutput = badgeTitles[requestedStat] + badgeRanks[i+5];
}
}
} else {
badgeOutput = "No Badges Available";
}
return badgeOutput;
}
나는 내 디자인이 아마 그것을 할 가장 매끄러운 방법이 아니라는 것을 알고, 그게 내가 가진거야. 내가 도대체 뭘 잘못하고있는 겁니까? 또한 다른 클래스의 전체 게시물이 있습니다. Difficulty navigating 2d String array that correlates to another 2d int array
당신은 명확하게 할 수 있습니까? 귀하의 코드는 if, loop, if/else와 유사합니다. 발사하지 않으면 어떡하지? – MiiinimalLogic
글쎄,'badgeRanks.length <5'이면 루프가 절대로 입력되지 않을 것입니다. – Eran
"이 코드가 작동하지 않는 이유는 무엇입니까? **") 디버그 도움말을 찾는 질문으로 닫으려면 원하는 동작, * 특정 문제 또는 오류 * 및 *이를 재현하는 데 필요한 가장 짧은 코드 *를 포함해야합니다. ** 문제가 명확하지 않은 질문 **은 다른 독자에게 유용하지 않습니다. [최소, 완전하며 검증 가능한 예제를 만드는 방법] (http://stackoverflow.com/help/mcve)). " 당신의 특별한 경우, 가장 큰 문제는 다음과 같습니다 : (1) 귀하의 모범이 최소 또는 완전하지 않다; (2) 적어도 나에게 당신이 원하는 행동을 분명하지 않다. – ruakh