Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

toString problems

807601Apr 30 2008 — edited Apr 30 2008
Im not sure if I need to post more code then this to get help, so if I do let me know
public boolean processGuess(int[] guess)
    {
        for(int i = 0; i < boardSize; i ++)
            guessHistory += (guess)+ " ";

String results = getGuessResults(guess);

guessHistory += " " + results + "\n";

return false; public String toString()
{
String boardString = "GUESS THE " + MysteryNumbersGame.numCnt + " NUMBERS"
+ "\nX X X X X \n\n X Correct number in the correct place."
+ "\n# Correct number in the wrong place.\n\nYour Guesses\n"
+ guessHistory;


return boardString;
Both of these methods are in the same class, and processGuess is called everytime the player guesses another set of numbers. Essentially its suppose to just put each guess and its results on a new line. But for some reason, when the toString is called (from another class), the only thing it registers from guessHistory is the nextline command and doesnt show the guess or the results...just skips a line.

Any help would be appriciated

Edited by: ollie88r on Apr 29, 2008 9:12 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 28 2008
Added on Apr 30 2008
6 comments
57 views