Skip to content

Commit 0ab38a9

Browse files
committed
finished exercises 1 to 6
1 parent 1c071de commit 0ab38a9

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/main/java/learnrxjava/ComposableListExercises.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ public <R> ComposableList<R> map(Function<T, R> projectionFunction) {
127127
// Note that you can apply a projectionFunction to a value like this:
128128
// projectionFunction.apply(5)
129129
// ------------ INSERT CODE HERE! ----------------------------
130-
130+
result.add(projectionFunction.apply(itemInList));
131131
});
132132

133-
//return results;
134-
throw new UnsupportedOperationException("Not implemented yet.");
133+
return results;
134+
//throw new UnsupportedOperationException("Not implemented yet.");
135135
}
136136

137137
/*
@@ -148,8 +148,10 @@ public static ComposableList<JSON> exercise5() {
148148
new Video(675465, "Fracture", 5.0));
149149

150150
// complete this expression
151-
// return newReleases.map(video ->
152-
throw new UnsupportedOperationException("Not implemented yet.");
151+
return newReleases.map(video -> {
152+
return json("id", video.id, "title", video.title)
153+
});
154+
// throw new UnsupportedOperationException("Not implemented yet.");
153155
}
154156

155157
/*
@@ -190,10 +192,13 @@ public static ComposableList<Video> exercise6() {
190192
// Insert code here that adds a video to the highRatedVideos list
191193
// if it has a rating of 5.0.
192194

195+
if(video.rating >= 5.0) {
196+
highRatedVideos.add(video)
197+
}
193198
});
194199

195-
// return highRatedVideos;
196-
throw new UnsupportedOperationException("Not implemented yet.");
200+
return highRatedVideos;
201+
// throw new UnsupportedOperationException("Not implemented yet.");
197202
}
198203

199204
/*

0 commit comments

Comments
 (0)