//import java.util.Scanner; import java.io.*; public class Driver { public static void main(String[] args) throws Exception { System.out.print("Loading database "); MovieDB mdb = new MovieDB(args[0]); System.out.println(); String commands = "actor (a), year (y), title (t), size (s), quit (q), help (h)"; System.out.println("\nMovie Database \n" + commands + "\n"); BufferedReader sc = new BufferedReader(new InputStreamReader(System.in)); System.out.print("> "); String command = sc.readLine(); while (!command.equals("quit") && !command.equals("q")){ if (command.equals("help") || command.equals("h")) System.out.println(commands); if (command.equals("size") || command.equals("s")) System.out.println(mdb.size() +" movies"); if (command.equals("actor") || command.equals("a")){ System.out.print("actor surname> "); String actor = sc.readLine(); for (Movie movie : mdb.getMovies()) if (movie.stars(actor)) System.out.println(movie.getTitle()); } if (command.equals("year") || command.equals("y")){ System.out.print("year> "); String year = sc.readLine(); for (Movie movie : mdb.getMovies()) if (movie.getYear().equals(year)) System.out.println(movie.getTitle()); } if (command.equals("title") || command.equals("t")){ System.out.print("title> "); String target = sc.readLine(); //while (sc.hasNext()) target = target + sc.next(); for (Movie movie : mdb.getMovies()) if (movie.titleMatch(target)) System.out.println(movie +"\n"); } System.out.print("> "); command = sc.readLine(); } } } // // NOTE: uses buffered i/o so that we can read a string with spaces :) //