We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 038369d commit 26aa027Copy full SHA for 26aa027
Week2/src/SecondRatings.java
@@ -1,5 +1,7 @@
1
import java.util.ArrayList;
2
import java.util.HashMap;
3
+import java.util.Map;
4
+import java.util.Objects;
5
6
/**
7
* Week2. A new class to do many of the calculations focusing on computing averages on movie
@@ -131,4 +133,19 @@ String getTitle(String id) {
131
133
// No title found
132
134
return "ID " + id + " NOT FOUND";
135
}
136
+ /*
137
+ * This method returns the movie ID of this movie.
138
+ * If the title is not found, return “NO SUCH TITLE.
139
+ * */
140
+ String getID(String title) {
141
+ String result = "NO SUCH TITLE";
142
+
143
+ for (Map.Entry<String, String> entry : moviesIdAndTitles.entrySet()) {
144
+ if (Objects.equals(title, entry.getValue())) {
145
+ return entry.getKey();
146
+ }
147
148
149
+ return result;
150
151
0 commit comments