Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Objects Creating the MVP Prompting for Guesses

Why don't we return isHit

In the video he says that we should see if the guess matches or not. And as far as I've understood we use the applyGuess method to check it. But if we want a Yes or No answer why don't we return isHit?

2 Answers

alastair cooper
alastair cooper
30,617 Points

Sorry, I think I understand your question better now.

This method is building and returning a string to indicate progress and has no variable named isHit to return. knowing whether it was a hit or not is only part of determining the progress.

Ok, I think I understand better now, thanks for the help. :)

alastair cooper
alastair cooper
30,617 Points

return it to where? it is in the main method!

When we return progress at the end, why don't we return isHit?

 public String getCurrentProgress() {
    String progress = "";
    for ( char letter : answer.toCharArray()); {
    char display = '-';
    if (hits.indexOf(letter) != -1) {
      display = letter;
    }
    progress += display;
  }
  return progress;
}