File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 11import java .util .ArrayList ;
22import java .util .HashMap ;
3+ import java .util .Map ;
4+ import java .util .Objects ;
35
46/**
57 * Week2. A new class to do many of the calculations focusing on computing averages on movie
@@ -131,4 +133,19 @@ String getTitle(String id) {
131133 // No title found
132134 return "ID " + id + " NOT FOUND" ;
133135 }
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+ }
134151}
You can’t perform that action at this time.
0 commit comments