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
Jack Hill
1,168 PointsAndroid Blog Reader
I need a little help The Instructions read: "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!"
I Have put this into the challenge and it says that it is still wrong. Please can anyone help me?
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", "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) {
this.id = id;
this.content = content;
this.director = director;
}
}
}
4 Answers
KUNAL HAJRA
5,288 PointsThe DummyItem constructor definition should be modified to accommodate the Director name. The director variable is set but is not set in the Constructor definition. The correct constructor definition should be
public DummyItem(String id, String content, String director) { this.id = id; this.content = content; this.director = director;
Zach Thacker
2,089 Pointsspaghetti
Zach Thacker
2,089 Pointsspaghetti
Michael Ikhane
2,390 PointsHi Jack,
I think it will be good for the community if you post the solution and mark it as best answer so we can learn from it and the issue can be sort of closed.
Thanks
Jack Hill
1,168 PointsJack Hill
1,168 PointsSince Uploading I have found the solution. So thank you to anyone who had read through it and was about to help me.