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

"Whoops looks like you forgot to remove the TODO'S after you completed them."

I get this error message "Whoops looks like you forgot to remove the TODO'S after you completed them. This helps everyone know it is done." after I submit my copy-pasted code.

I have since corrected the error by deleting all lines containing "TODO" but it still gives me that error.

I glanced at some of the other threads related to this topic and I tried to correct the error by prompting user for a new/different story than default story in Main.java, but I still get the same error.

Code runs correctly on the my IDE. Can someone copy-paste into their session and see if they get the same error?

So I tried copy-pasting other people's solutions and I get the same TODO error. I think it's a bug with whatever you are using to unit test my submitted code.

com/teamtreehouse/Main.java
// After you've completed the TODOs locally paste Main.java here

package com.teamtreehouse;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

public class Main {

    public static void main(String[] args) {

        Prompter prompt = new Prompter();
        Template tmpl = null;

        try {
            tmpl = new Template(prompt.promptForStory());
        } catch (IOException ioe) {
            ioe.printStackTrace();
        }

        prompt.run(tmpl);

    }
}
com/teamtreehouse/Prompter.java
// After you've completed the TODOs locally paste Prompter.java here

package com.teamtreehouse;

import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.logging.ConsoleHandler;


public class Prompter {
    private BufferedReader mReader;
    private Set<String> mCensoredWords;

    public Prompter() {
        mReader = new BufferedReader(new InputStreamReader(System.in));
        loadCensoredWords();
    }

    private void loadCensoredWords() {
        mCensoredWords = new HashSet<String>();
        Path file = Paths.get("resources", "censored_words.txt");
        List<String> words = null;
        try {
            words = Files.readAllLines(file);
        } catch (IOException e) {
            System.out.println("Couldn't load censored words");
            e.printStackTrace();
        }
        mCensoredWords.addAll(words);
    }

    public void run(Template tmpl) {
        List<String> results = null;
        try {
            results = promptForWords(tmpl);
        } catch (IOException e) {
            System.out.println("There was a problem prompting for words");
            e.printStackTrace();
            System.exit(0);
        }

        System.out.printf("Your TreeStory:%n%n%s", tmpl.render(results));
    }

    /**
     * Prompts user for each of the blanks
     *
     * @param tmpl The compiled template
     * @return
     * @throws IOException
     */
    public List<String> promptForWords(Template tmpl) throws IOException {
        List<String> words = new ArrayList<String>();
        for (String phrase : tmpl.getPlaceHolders()) {
            String word = promptForWord(phrase);
            words.add(word);
        }
        return words;
    }


    /**
     * Prompts the user for the answer to the fill in the blank.  Value is guaranteed to be not in the censored words list.
     *
     * @param phrase The word that the user should be prompted.  eg: adjective, proper noun, name
     * @return What the user responded
     */
    public String promptForWord(String phrase) throws IOException{
        String input = "";

        do {
            System.out.printf("Enter a %s %n", phrase);
            input = mReader.readLine();
        } while( mCensoredWords.contains(input.toLowerCase()) );

        return input.trim();
    }

    public String promptForStory() throws IOException{
        System.out.println("Make a story! Write a fill in the blank story with an underscore on each side of the variable like _noun/adjective/etc_");
        String story = mReader.readLine();

        // default if user is too lazy to type a story.
        if( story.equals("") ){
            story = "Hello __noun__ i am feeling __adjective__ today!";
        }

        return story;
    }
}
pseudo-tests.md
#  This is essentially what I am testing 
1.  The user is prompted for a new string template (the one with the double underscores in it).

  a. The prompter class has a new method that prompts for the story template, and that method is called.

2.  The user is then prompted for each word that has been double underscored.

   a. The answer is checked to see if it is contained in the censored words.
      User is continually prompted until they enter a valid word

3.  The user is presented with the completed story

1 Answer

Wow! I can't believe how silly the problem was.

Delete the commented lines: "// After you've completed the TODOs locally paste Prompter.java here" on both Main.java and Prompter.java because for some reason it triggers your badly designed regex checker and gives a false error of leaving TODO's. Maybe change the regex to included your name initials or something. If this were using a compiler behind the scenes, should have ignore the double-slash comments.

I spent WAY MORE time that I should debugging this than I should have or needed to once I had the correct solution. A beginner to this would probably get frustrated and quit.

Daniel Ingolfsson
Daniel Ingolfsson
3,458 Points

I spent hours struggling with this problem set and in the end, I had the same problem as you.

It didn't help that the compiler on TeamTreeHouse kept crashing over and over again.