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 trialBrad Pizzimenti
14,640 Points20 errors... after adding these changes can't find symbols for any of my methods.
Not sure how prompter seems to be missing all methods of mGame. Is there something in my code that decoupled prompter from game class?
//Prompter.java
import java.io.Console;
public class Prompter {
private Game mGame;
public Prompter(Game game) {
mGame = game;
}
public void play() {
while (mGame.getRemainingTries() > 0) {
displayProgress();
promptForGuess();
}
}
public boolean promptForGuess() {
Console console = System.console();
boolean isHit = false;
boolean isValidGuess = false;
while (! isValidGuess) {
String guessAsString = console.readLine("Enter a letter: ");
char guess = guessAsString.charAt(0);
try {
isHit = mGame.applyGuess(guess);
isValidGuess = true;
} catch (IllegalArgumentException iae) {
console.printf("%s. Please try again. \n", iae.getMessage());
}
}
return isHit;
}
public void displayProgress() {
System.out.printf("You have %d tries left to solve: Try to solve: %s\n",
mGame.getRemainingTries(),
mGame.getCurrentProgress());
}
}
3 Answers
Brad Pizzimenti
14,640 PointsFound it! Looks like I was missing a close } at the end of my validateGuess() method.
I exported the text into Atom and once in there I could see that all of my methods further down had goofy syntax highlighting.
Oh syntax highlighting! I rely on it too much to know what's wrong!
Henning Bang Halvorsen
16,239 PointsJust a little something... In your contructor, try to indent mGame = game; It seems you can't access the game object, so I guess something is wrong when you assign game to mGame.
Brad Pizzimenti
14,640 PointsHrm... Didn't help. I don't think java cares about white space (either horizontal or vertical). Thanks for the suggestion though.
Brad Pizzimenti
14,640 PointsBrad Pizzimenti
14,640 Points