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
Uriah Nevins
1,121 PointsError: not a statement.
I am really irritated, because I am following the video exactly and I have no Idea what is going wrong with my code. I'm getting an error that ">=" is not a statement. The other problem is, it's in my "Game.java" file, which he does not open at all in the video! I need some help. https://teamtreehouse.com/workspaces/15164682#
jcorum
71,830 PointsUriah, we need a bit more in order to be of any help. Can you include your code? Can you provide a link to the challenge you are having trouble with?
Andrew Winkler
37,739 Pointsfyi: the to the workspace that you posted does not connect to anything...
Uriah Nevins
1,121 PointsThat first link worked for me. It took me right to my workspace. Maybe it is restricted to anyone but the creator? How do I show you another way?
Uriah Nevins
1,121 Points//Prompter.java file
import java.io.Console;
public class Prompter{
private Game mGame;
public Prompter(Game game){
mGame = game;
}
public boolean promptForGuess(){
Console console = System.console();
String guessAsString = console.readLine("Enter a letter: ");
char guess = guessAsString.charAt(0);
return mGame.applyGuess(guess);
}
}
//Game.java file (where it found the error)
import java.io.Console;
public class Prompter{
private Game mGame;
public Prompter(Game game){
mGame = game;
}
public boolean promptForGuess(){
Console console = System.console();
String guessAsString = console.readLine("Enter a letter: ");
char guess = guessAsString.charAt(0);
return mGame.applyGuess(guess);
}
}
//Hangman.java file
public class Hangman {
public static void main(String[] args) {
// Enter amazing code here:
Game game = new Game("treehouse");
Prompter prompter = new Prompter(game);
boolean isHit = prompter.promptForGuess();
if (isHit){
System.out.println("It's a hit!");
}
else{
System.out.println("Whoops! We got a miss.");
}
}
}
1 Answer
Andrew Winkler
37,739 PointsI get a page that says "Bummer. It appears the page you're looking for doesn't exist."
I would just copy and paste the code. We can sift through it. It's what we do here.
Uriah Nevins
1,121 PointsUriah Nevins
1,121 Pointshere is the link to the video: https://teamtreehouse.com/library/java-objects/creating-the-mvp/prompting-for-guesses