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 trialStanley Blackman
4,204 PointsNot understanding how to fix this...
./Prompter.java:11: error: bad operand type boolean[] for unary operator '!'
while (mGame.getRemainingTries() > 0 && !mGame.isSolved()) {
^
./Prompter.java:15: error: incompatible types: boolean[] cannot be converted to boolean
if (mGame.isSolved()) {
^
9 errors
import java.io.Console;
public class Prompter { private Game mGame;
public Prompter(Game game) { mGame = game; }
public void play() { while (mGame.getRemainingTries() > 0 && !mGame.isSolved()) { displayProgress(); promptForGuess(); } if (mGame.isSolved()) { System.out.printf("Congratulations you won with %d tries remaining.\n", mGame.getRemainingTries()); }else { System.out.printf("Bummer the word was %s. :(\n", mGame.getAnswer()); } }
public boolean promptForGuess() { Console console = System.console(); boolean isHit = false; boolean isValidGuess = false; while (! isValidGuess) { String guessAsString = console.readLine("Enter a letter lil bih: "); try { isHit = mGame.applyGuess(guessAsString); 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: %s\n", mGame.getRemainingTries(), mGame.getCurrentProgress()); }
}
1 Answer
Cindy Lea
Courses Plus Student 6,497 PointsWithout seing all the code all I can do is offer a suggestion that Treehouse suggested in the past:
public boolean isSolved() { return getCurrentProgress().indexOf('-') == -1; } public void play() { while (mGame.getRemainingTries() > 0 && !mGame.isSolved()) { displayProgress(); promptForGuess(); } if (mGame.isSolved()) { System.out.printf("YAAAY, You won!!"); } else { System.out.printf("You LOST :-(.\n The answer was: %s", mGame.getAnswer()); } }
Stanley Blackman
4,204 PointsStanley Blackman
4,204 Pointscould you explain to me how I would upload a visual representation to you please?