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 Local Development Environments Advanced Tooling Finishing TreeStory

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

Is this normal?

Is it normal that when I get to this code challenge, having gone through the video and with all of my knowledge of Java that I have precisely no idea how to start solving the TODO's of this code challenge?

I know the answer must be within me somewhere. I try to clear my mind and think logically but when I go back into... lets say the prompter java file I look at the to do and I can barely understand what the question is asking of me let alone how to solve it.

// TODO:csd - Print out the results that were gathered here by rendering the template

I guess that means use a forloop to print all the results but then what does rendering template mean?

Okay... maybe I'll come back to that.

Maybe I need to start from the main.java file.

// TODO:csd - Instantiate a new Prompter object and prompt for the story template

Hmm okay so I'm supposed to create a new constructor function named Prompter and write some variables so I can start prompting users to fill in the words needed to complete story? Am I making a new story or the same story?

How do I get over this feeling that I'm totally unprepared to go do this code challenge on my own?

Help

From Lost ;)

1 Answer

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

Try to think literally what he means:

// TODO:csd - Print out the results that were gathered here by rendering the template

We print using System.out.println() right? So this command definitely goes here.

What is inside. Key words: results rendered by template. Let's literally convert it to Java:

results = template.render();

Does it look familiar? Then you think: Aha in the method run we have Template tmpl as argument. So probably there we should use this template right? After all that's why this TODO is here.

Then let's look for a method. There should be method used on this template called render... Template.render() - check it.

Check what arguments it takes List<String>.

Hmm... Looks like I've seen List<String> already in the run method, right ? :)

So our method changes to :

template.render(someListStrings);

And finding proper List<String> you can connect everyting and put template.render expresssion in println().

I tried to be as much hinting as possible on this one. I'm sure you can connect the rest :)

About the second TODO, you are almost there. Think literally:

Hmm okay so I'm supposed to create a new constructor function named Prompter

That is correct : first line is done:

Prompter prompter = new Prompter();

Now second part: don't go too far. This is too far:

and write some variables so I can start prompting users to fill in the words needed to complete story

Literally convert his words to Java : prompt for the story template

storyTemplate = promptForStory();

Does not look right. You look at the code above and see this :

String story = "Thanks __name__...";

So you need to prompt for story like String story above, so probably method promptForStory() should return String and all he does - is literally prompts user for story.

The important question is: where to put your method? Hmm... We have Prompter class, looks like prompting method should go just there, so your code changes to

String story = prompter.promptForStory();

I believe from this you can go for method promptForStory() and write it : )

I tried my best to give you hints. May be it will give you nothing. It is how I understand Craig's tasks : )

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,253 Points

Thanks I'll see what I can do with these hints.

Maybe I'm going to fast. I was expecting the video to go into depth on the VCS compatibility of Intellij. Next thing I know I'm being asked to finish half a Java Application and suddenly I'm feeling way out of my depth.

But I guess that's an illusion and I'm not being asked to do anything we haven't done already in the previous examples.

I just wish he'd have challenged us another way by encouraging us to try it ourselves and coding out the answer in another video,

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

Great quote:

But I guess that's an illusion and I'm not being asked to do anything we haven't done already in the previous examples.

If you like challenges, Java Web Dev Techdegree is the road full of challenges. Project number 2 - is just like this Treestory but to write from zero.

However, he'll ask you to do something and then show how he did in more advanced courses, like 'Spark REST workshop'. There was quite challenging for me. And the level of code he writes there is much higher, so there he will ask you to pause him, try yourself, and then show solution.

I just wish he'd have challenged us another way by encouraging us to try it ourselves and coding out the answer in another video,

I think it is a great idea. It could've been great if he'd put just User stories for 'TreeStrory' project and then coded it on his own. But:

  1. first of all this course is called 'LDE', so well such kind of project does not fit here
  2. You could've done that with KaraokeMachine in previous course. I did that BTW: first tried Items in Backlog on my own, then watched his result, and it was pretty fruitful for me
  3. We have techdegree. That is exactly the place where person can try things on his own, get graded, or asked

So, all in all this 'TreeStory' challenge is just to give us feeling how nice it is to write code in IDE, and not in Workspace :) and that I think he'd managed

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,253 Points

Having used the IDE more and more in the last few weeks I can see how useful it is and it does point me in the right direction more often than not. But I did try the first todo and I'm just not getting it. This could take a while for me to pass but I'll keep trying :)