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

The hangman Game

Game.java

public class Game { public static final int MAX_MISSES = 7; private String mAnswer; private String mHits; private String mMisses;

private char validateGuess(char letter) { if (! Character.isLetter(letter)) { throw new IllegalArgumentExecption("A letter is required"); } letter = Character.toLowerCase(letter); if(mHits.indexOf(letter) >= 0 || mMisses.indexOf(letter) >=0) { throw new IllegalArgumentException(letter + "has already been guessed"); } return letter; } public Game(String answer) { mAnswer = answer; mHits = ""; mMisses = ""; } public boolean applyGuess(char letter) { letter = validateGuess(letter); boolean isHit = mAnswer.indexOf(letter) >= 0; if (isHit) { mHits += letter; } else { mMisses += letter; }
return isHit; } public String getCurrentProgress() { String progress = ""; for (char letter: mAnswer.toCharArray()) { char display = '-'; if (mHits.indexOf(letter) >= 0) { display = letter; }
progress += display; } return progress; } public int getRemainingTries() { return MAX_MISSES - mMisses.length(); }
}

Picked up JAVA_TOOL_OPTIONS: -Xmx128m
Picked up _JAVA_OPTIONS: -Xmx128m
./Game.java:9: error: cannot find symbol
throw new IllegalArgumentExecption("A letter is required");
^
symbol: class IllegalArgumentExecption
location: class Game
1 error

Why I get this error everything seems right I checked the video as well

1 Answer

Hi Nirbhay, It seems that you have misspelled Exception as Execption.

Hope this helps! Best Regards, Philip

Oh my bad thanks Philip

Glad it worked! You can mark the response as an answer to let others know your problem has been resolved :)