0
오델로 게임에 대한 이동이 합법적인지 확인하려고합니다. 검사 할 변수를 사용할 때마다 각 루프마다 한 번 (한 번만) 사용합니다. '오류를 해결할 수 없습니다.'라는 메시지가 나타납니다. 나는 이것이 일어나는 곳을 굵게 보았다. 누구든지 도와 줄 수 있습니까? (그래, 난 내가 처음이 오류를 제거하기 위해 노력하고있어, 코드가 아직 완료되지 않았 음을 알 수 있습니다.) 몸없이이 코드에서 "해결할 수 없음"오류가 나타나는 이유는 무엇입니까?
public boolean isLegal(Location loc1)
{
String currentColor = currentPlayer.getColor();
boolean isLegal = false;
int row = loc1.getRow();
int col = loc1.getCol();
if(board.isValid(loc1))
{
if(board.get(loc1) == null)
{
for(Location tempLoc : board.getValidAdjacentLocations(loc1))
{
if(!board.get(tempLoc).equals(currentColor))
{
int tempRow = tempLoc.getRow();
if((row != tempLoc.getRow()) && (col == tempLoc.getCol()))
{
//count up column
if(**tempLoc.getRow()** < row)
{
for(int i = row; i > 1;)
{
Location tempLoc2 = new Location(i-2, col);
if(!board.get(tempLoc2).equals(currentColor))
{
i--;
}
else
{
i=-1;
isLegal = true;
}
}
}
//count down column
else
{
for(int i = row; i < 6;)
{
Location tempLoc2 = new Location(i+2, lcol);
if(!board.get(tempLoc2).equals(currentColor))
{
i++;
}
else
i=9;
isLegal = true;
}
}
}
else if(col != tempLoc.getCol() && row == tempLoc.getRow())
{
//count left/right row
if(col > tempLoc.getCol())
{
}
else
}
else
{ //count up/right & down/left diag
if(1!=0)
{
}
//count up/left & down/right diag
else
}
}
}
}
}
return isLegal;
}
아마도 바닥에있는 빈'else' 문에 두 가지 더 많은 컴파일 오류가있을 것입니다. 이걸 수정하면 어떤 변화가 있습니까? (예를 들어, 그 뒤에 {}를 넣음으로써) 컴파일러는 당신의 메소드 내부에 무엇이 포함되는지 혼동 할 수 있습니다. –
사실 그 문제가 해결되었습니다! 고맙습니다! 나는 왜 내가 그런 생각을하지 않았는지 궁금해. ... ^^; – frozenxdreamer
@RussellZahniser 당신은 이것을 받아 들일 수 있도록 대답으로 게시해야합니다. –