**
이 이동하고 추가 이동 후 checkForWin의 운전 방식을이기는 이상이 고모 쿠 게임 제작에 여분의 이동 원인은이 직후 checkForWin 방법이어야 승리를 감지 방법하지만 입니다 해당 makeMove 메서드입니다.왜 checkforWin (File f)이 true 일 때 true를 반환하지 않습니까?
**
import java.io.File;
boolean hasWinner = false;
File gameFile = new File("src/centralGameFile.txt");
do{
//player 1
makeMove(gameFile);
// check for win
if (checkForWin(gameFile)){
hasWinner = true;
break;
}
// player 2
makeMove(gameFile);
// check for win
if (checkForWin(gameFile)){
hasWinner = true;
break;
}
}while(hasWinner == false);
System.out.println("somebody has won the game");
/*this method is located in another class in the same package and is
called from an instance of the class using the access operator */
protected boolean checkForWin(File f){
//return true if the file has a winner in it using scanner to look for it
//this method works correctly when tested with just a file in a test class
}
// 간결
/* makeMove(File f) method copies the text from f and over writes
it adding another character; in context this is a gomoku/tic-tac-toe
style game but on a bigger board.
*/
원인이 될 수 있는지를 결정하기 너무 적은 정보가 있습니다. 예를 들어,'checkForWin'에 무엇이 있습니까? – bas
전체 "do loop"는 거의 동일합니다 do { makeMove (gameFile); } while (! checkForWin (gameFile)); –
더 나은 도움을 받으려면 [SSCCE] (http://sscce.org/)를 게시하십시오. –