import java.util.Scanner; public class OldDriver { 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"); Scanner sc = new Scanner(System.in); System.out.print("> "); String command = sc.next(); 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()); if (command.equals("actor") || command.equals("a")){ System.out.print("actor surname> "); String actor = sc.next(); for (Movie movie : mdb.getMovies()) if (movie.stars(actor)) System.out.println(movie +"\n"); } if (command.equals("year") || command.equals("y")){ System.out.print("year> "); int year = sc.nextInt(); for (Movie movie : mdb.getMovies()) if (movie.getYear() == year) System.out.println(movie.getTitle()); } if (command.equals("title") || command.equals("t")){ System.out.print("title> "); String target = sc.next(); //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.next(); } } } // // NOTE: this uses scanner anmd not buffered i/o // so cannot read a string with spaces :( //