// Jim Herrero import java.io.*; import java.util.*; public class MovieTest { public static void main() throws IOException { Scanner sc = new Scanner(new File("movies.txt")); ArrayList movies = new ArrayList(); int year; String line, title; String[] names; LinkedList actors; Person director; while(sc.hasNext()) { line = sc.nextLine(); year = Integer.valueOf(line.substring(0, 4)); title = line.substring(5, 36); //trim? names = line.substring(38, 84).split(", "); //trim? actors = new LinkedList(); for(String actor : names) actors.add(new Person(actor.substring(0, actor.indexOf(" ")), actor.substring(actor.indexOf(" ") + 1))); names = line.substring(89).split(" "); //trim? director = new Person(names[0], names[1]); movies.add(new Movie(year, title, director, actors)); } Collections.sort(movies); int numActors = 0; for(Movie thismovie : movies) { System.out.println(thismovie); for(Person thisactor : thismovie.getActors()) numActors++; } System.out.println(numActors + " actors total"); } }