We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent eea3556 commit e5d121cCopy full SHA for e5d121c
Week4/src/FourthRatings.java
@@ -0,0 +1,24 @@
1
+import java.util.ArrayList;
2
+
3
+/**
4
+ * The week 4 class
5
+ *
6
+ * @author Stanislav Rakitov
7
+ * @version 1.0
8
+ */
9
+public class FourthRatings {
10
11
+ private Double getAverageByID(String movieID, Integer minimalRaters) {
12
+ ArrayList<Rater> myRaters = RaterDatabase.getRaters();
13
+ long numOfRatings = myRaters.stream().filter(rater -> rater.hasRating(movieID)).count();
14
15
+ if (numOfRatings >= minimalRaters) {
16
+ return myRaters.stream()
17
+ .filter(rater -> rater.hasRating(movieID))
18
+ .mapToDouble(rating -> rating.getRating(movieID))
19
+ .average()
20
+ .orElse(0.0);
21
+ }
22
+ return 0.0;
23
24
+}
0 commit comments