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 trialMagdalena Frankowska
15,501 PointsPlease try again
in Prompter. java we have the part that says
System.out.printf("%s. Please try again. %n",
iae.getMessage());
When Craig puts a number through or puts through a letter that has already been used it just says "a letter is required" or "x has already been guessed" but when i do it it says "A letter is required, please try again" or "x has already been guessed, please try again. Did I do sth wrong or is there sth wrong with the original code that it doesn't display "please try again"? I'm lost.
Kristopher Goodwin
632 PointsKristopher Goodwin
632 PointsI just did this video, so I am in no way an expert, but this is what I believe is happening.
The %s is capturing the iae.getMessage()); illegal exception message from the game class. The "Please try again." is there regardless, with the illegal exception message being pasted in front of it.
In the Game.java, the two messages are "A letter is required." and (letter + " has already been guessed.");
So regardless, because of the System.out.printf("%s. Please Try again <---- This is pasted on whatever message it grabs that is throwing the exception.
Oops. I think I just realized what you were asking; It appears when he ran it, he did not save it. (There is a red dot on his .java file). However, it showing "Please try again." after each one I believe is the way it is supposed to work.