import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Collections; import java.util.HashMap; import java.util.Map; public class Movies { public static Map> mainList = new HashMap>(); public static void main(String[] args) { addMovie("Harry Potter and the Sorcerer's Stone", Arrays.asList("Harry Potter", "Hermione Granger", "Ron Weasley", "Albus Dumbledore"), Arrays.asList("Daniel Radcliffe", "Emma Watson", "Rupert Grint", "Richard Harris")); addMovie("Ghost World", Arrays.asList("Enid", "Rebecca", "Seymour"), Arrays.asList("Thora Birch", "Scarlett Johansson", "Steve Buscemi")); for(String title : listMovies()){ System.out.println(title); } System.out.println("========"); System.out.println(findActor("Harry Potter and the Sorcerer's Stone", "Ron Weasley")); System.out.println(findActor("Harry Potter and the Sorcerer's Stone", "Harry Potter")); System.out.println(findActor("Harry Potter and the Sorcerer's Stone", "Hairy Potter")); System.out.println("========"); showCast("Harry Potter and the Sorcerer's Stone"); System.out.println("========"); showCast("Hairy Potter"); } private static void addMovie(String title, List characters, List actors) { // TODO fill in this stuff Map movie = makeMap(characters, actors); mainList.put(title, movie); } private static Map makeMap(List keys, List values){ Map mpa = new HashMap(); for (int i = 0; i < keys.size(); i++){ mpa.put(keys.get(i), values.get(i)); } return mpa; } private static List listMovies() { // TODO fill in this stub return new ArrayList(mainList.keySet()); } private static String findActor(String title, String character) { // TODO fill in this stub Map newMap = mainList.get(title); if (newMap == null){ System.out.println("Jason says NO!"); } String jason = newMap.get(character); if (jason == null) System.out.println("Jason says NO NO"); return jason; } private static void showCast(String title) { // TODO fill in this stub } }