Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Blog Reader Android App Exploring the Master-Detail Template Adding More Test Data

Zubeyr Aciksari
Zubeyr Aciksari
21,074 Points

Hi guys, i am stuck in here, can someone please send the code? Thanks!

Update the DummyItem constructor to set the new 'director' member variable to a third parameter also named ‘director’. Then go back and add director last names to the items. Bonus points if you use the correct directors for the movie!

DummyContent.java
public class DummyContent {

    public static List<DummyItem> ITEMS = new ArrayList<DummyItem>();
    public static Map<String, DummyItem> ITEM_MAP = new HashMap<String, DummyItem>();

    static {
        // Add 3 sample items.
        addItem(new DummyItem("1", "The Avengers", "Whedon 1"));
        addItem(new DummyItem("2", "The Hobbit", "Jackson 2"));
        addItem(new DummyItem("3", "Ball of Fire", "Hawks 3"));
    }

    private static void addItem(DummyItem item) {
        ITEMS.add(item);
        ITEM_MAP.put(item.id, item);
    }

    /**
     * A dummy item representing a piece of content.
     */
    public static class DummyItem {
        public String id;
        public String content;
        public String director;

        public DummyItem(String id, String content, String director) {
            this.id = id;
            this.content = content;
            this.director= director;
        }
    }
}

1 Answer

The only thing I can see different is the lack of space in your constructor assignment to director.

This code passes:

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DummyContent {

    public static List<DummyItem> ITEMS = new ArrayList<DummyItem>();
    public static Map<String, DummyItem> ITEM_MAP = new HashMap<String, DummyItem>();

    static {
        // Add 3 sample items.
        addItem(new DummyItem("1", "The Avengers", "Dave"));
        addItem(new DummyItem("2", "The Hobbit", "Steve"));
        addItem(new DummyItem("3", "Ball of Fire", "Brian"));
    }

    private static void addItem(DummyItem item) {
        ITEMS.add(item);
        ITEM_MAP.put(item.id, item);
    }

    /**
     * A dummy item representing a piece of content.
     */
    public static class DummyItem {
        public String id;
        public String content;
        public String director;

        public DummyItem(String id, String content, String director) {
            this.id = id;
            this.content = content;
            this.director = director;
        }
    }
}