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 trialJiten Mistry
4,698 PointsConfused on TODO2:
Ive tried creating a new list of video objects and adding the newly created video, but the comment says add to second video. i think I'm misunderstanding what is being asked
package com.example.model;
import java.util.List;
public class Course {
private String mName;
private List<Video> mVideos;
public Course(String name, List<Video> videos) {
mName = name;
mVideos = videos;
}
public String getName() {
return mName;
}
public List<Video> getVideos() {
return mVideos;
}
}
package com.example.model;
public class Video {
private String mTitle;
public Video(String title) {
mTitle = title;
}
public String getTitle() {
return mTitle;
}
public void setTitle(String title) {
mTitle = title;
}
}
import com.example.model.Course;
import com.example.model.Video;
import java.util.Map;
public class QuickFix {
public void addForgottenVideo(Course course) {
// TODO(1): Create a new video called "The Beginning Bits"
Video tbb = new Video("The Beginning Bits");
// TODO(2): Add the newly created video to the course videos as the second video.
}
public void fixVideoTitle(Course course, String oldTitle, String newTitle) {
}
public Map<String, Video> videosByTitle(Course course) {
return null;
}
}
2 Answers
Chris Howell
Python Web Development Techdegree Graduate 49,702 PointsI can see how you may have misread TODO 2.
I will see if rephrasing helps.
For TODO2 you are going to take the video you just created in TODO 1 and add it to the Course List of Videos. List doc But they want you to not JUST add it into the list they want you to place it in a specific spot in the List.
Remember a List has integer indexes that you can use to retrieve and add things with. HINT HINT.
Since addForgottenVideo takes a Course as a parameter, you can use the course variable to make your calls to retrieve your List of videos.
Andrea Miotto
iOS Development Techdegree Graduate 23,357 Pointspublic void addForgottenVideo(Course course) {
// TODO(1): Create a new video called "The Beginning Bits"
Video tbb = new Video("The Beginning Bits");
// TODO(2): Add the newly created video to the course videos as the second video.
course.add(1, tbb); //add(int index, E element)
}
Jiten Mistry
4,698 PointsJiten Mistry
4,698 PointsThank you again Chris, Rephrasing it, was all i needed. Much appreciated it!