Hey guys I developed a method called processGuess which gets an array of ints passed to its parameter, adds the guess and its results to the guessHistory string and then returns a boolean depending if the guess is a winner or not. heres my algorithm:
public boolean processGuess(int[] guess)
{
for(int i=0;i<boardSize;i++)
{
guessHistory+=guess[i]+" ";
}
guessHistory+="\t"+getGuessResults(guess)+"\n";
String mysteryNums=getMysteryNumbers();
String theResults=getGuessResults(guess);
boolean haveWinner=false;
if(mysteryNums.length()==theResults.length())
{
haveWinner=true;
for(int i=0;i<theResults.length();i++)
{
if(theResults.charAt(i)!='X')
{
haveWinner=false;
}
}
}
return haveWinner;
} // end method processGuess
the logic is if the guess results is the same length as the mystery numbers haveWinner is true and provided that all characters in the results are 'X" (a correct number in the correct position) then haveWinner remains true but the first character that is a # haveWinner is set to false. This seems logical but it isn't declaring a winner when the correct numbers are guessed.