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 trialKehinde Oseni
2,485 PointsMy Hangman code is not prompting for a guess
public class Hangman {
public static void main(String[] args) {
// Your incredible code goes here...
Game game = new Game("treehouse");
Prompter prompter = new Prompter(game);
boolean isHit = prompter.promptForGuess();
if (isHit) {
System.out.println("We got a hit!");
} else {
System.out.println("Oops missed");
}
}
}
[MOD: formatted code block - srh]
2 Answers
Steve Hunter
57,712 PointsHi there,
This line:
boolean isHit = prompter.promptForGuess();
... calls the promptForGuess()
method in the Prompter
class. That's what should be prompting the user for input. Can you share your Prompter
code as it seems the error may lie in there?
Steve.
Anand Altekar
1,790 PointsSame problem here. Any answers yet?
Anand Altekar
1,790 PointsGot it!
boolean isHit = "P"rompter.promptForGuess();
that p has to be capital. remove the double quotes, they are just to highlight that p here.