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
Nick Judd
10,745 PointsJust managed to complete the Local Dev Env final challenge...
The thing took me like 3 hours!! I'm pretty stoked that I got it though.
TBH, I found the todo's in the code a bit confusing at first, I wasn't sure if I was meant to use the 'story' String provided initially, or prompt for one.. obviously we needed to, but I wasn't sure how much I could edit the code at first until I just started tweaking things until it matched the requirements.
Some observations - I still don't really understand how IOException works - I can see why its required for importing files, but I was forced to throw it on the methods I created to prompt for the story String. At first I tried to do this in the prompter constructor but then I needed to throw the IOException from the main method which both seems messy, and caused an error on the test script. I don't really understand why its required in the class/method that calls the method which uses it.
(I got around this by prompting the user in a setter method for the story, then fed the getter for that in to the template constructor.)
When I made a try/catch pair, I had it print "ERROR" before exiting, but when I entered an integer for the story it just exited without printing anything. It compiles and runs fine, but it doesn't print "ERROR!" as expected on an illegal input:
try {
prompt.setMyStory(); //this calls readLine() and takes console input (String)
} catch (IOException e) {
e.printStackTrace();
System.out.println("ERROR!");
System.exit(0);
}
When I run it:
<ul> <li>Please enter your story: </li> <li>1234</li> <li>1234</li> <li></li> <li>Process finished with exit code 0</li> </ul>
If anyone can shine some light on this I would appreciate it.
It also takes me an insanely long time to follow code around different classes/methods.. does this improve over time?
Thanks!
Nick
1 Answer
Daniel Hartin
18,106 PointsHi Nick
If i'm understanding you correctly and your call to setMyStory() is simply a ReadLine method entering 12341234 will not cause an error "12341234" can still be a string, the problem only occurs when you expect a number value and pass it something like "hello world".
The call to ReadLine() can cause an IOException as shown in the docs http://docs.oracle.com/javase/7/docs/api/java/io/Console.html which is no doubt why it's asking to be wrapped in a try/catch block
Hope this helps Daniel