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 trialMUZ140073 Lionell Matambanadzo
12,509 Pointsplease assist me with this challenge Exploring the Master Detail Template.
Add two more DummyItems to this list, with two more movie titles. Make sure to give them IDs of "4" and "5" to follow the pattern.
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 {
addItem(new DummyItem("1", "The Avengers"));
addItem(new DummyItem("2", "The Hobbit"));
addItem(new DummyItem("3", "Ball of Fire"));
addItem(new DummyItem("1", "Item 1"));
addItem(new DummyItem("2", "Item 2"));
addItem(new DummyItem("3", "Item 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 DummyItem(String id, String content) {
this.id = id;
this.content = content;
}
}
}
2 Answers
Gunjeet Hattar
14,483 Points addItem(new DummyItem("1", "The Avengers"));
addItem(new DummyItem("2", "The Hobbit"));
addItem(new DummyItem("3", "Ball of Fire"));
addItem(new DummyItem("1", "Item 1"));
addItem(new DummyItem("2", "Item 2"));
addItem(new DummyItem("3", "Item 3"));
}
You have added three of them. Add only two and continue with 4 after Dummyitem 3. You have started from 1 again.
Hope that explains
MUZ140073 Lionell Matambanadzo
12,509 PointsThank you sir