CSc 4710/6710 Database Systems
Fall 2011
Homework 7
Due: December 4, 2011 (Sunday)

Implement an Java application for the theater-screen-movie-show database of exam 2 using db4o. Here is the database schema. Note that only the variables are provided in each of the classes. You need to write the constructor, getters and setters, and toString().

  1. CreateDatabase.java. to be run as
    $ java CreateDatabase movies.db4o
    

    This program creates a db4o database and populates it with the following objects:

    // movie objects
    Movie m1 = new Movie(100,"Star Wars","USA",1978);
    Movie m2 = new Movie(101,"Gandhi","UK",1982);
    Movie m3 = new Movie(102,"Ran","Japan",1972);
    Movie m4 = new Movie(103,"Sting","USA",1976);
    Movie m5 = new Movie(104,"Wizard of Oz","USA",1948);
    Movie m6 = new Movie(105,"Money Ball","USA",2009);
    
    // theater objects
    Theater t1 = new Theater(1,"Odeon","Atlanta");
    Theater t2 = new Theater(2,"Multiplex I","Doraville");
    Theater t3 = new Theater(3,"Multiplex II","Atlanta");
    
    // screens in theater 1
    Screen s11 = new Screen(1,"North I");
    Screen s12 = new Screen(2,"North II");
    Screen s13 = new Screen(3,"North III");
    Screen s14 = new Screen(4,"West I");
    
    // screens in theater 2
    Screen s21 = new Screen(1,"Magnolia I");
    Screen s22 = new Screen(2,"Magnolia II");
    Screen s23 = new Screen(3,"Orchid I");
    
    // screens in theater 3
    Screen s31 = new Screen(1,"Galleria I");
    Screen s32 = new Screen(2,"Galleria II");
    
    // sample show object - movie m1 in screen s11
    Show h1 = new Show(new Date(2011,11,15,12,0,0),20);
    
    The show objects are available in the file show.pdf. The program should create the above objects and set all links (both forward and reverse links).
  2. QueryDatabase.java. This program implements the following menu options:
    $ java QueryDatabase movies.db4o
    
    Menu Options
      1. Movie Statistics
      2. Show Listings
      3. Quit
    
    Enter your option:
    

    For option 1, prompt user for movie number; compute total visitors in all theaters and total ticket sales for the movie (assume $5 per ticket for 12.00 and 3.00 shows and $8 per ticket for 6.00 and 9.00 shows)

    For option 2, prompt user for movie number and city; find all shows for movie in city and print (in a nice format).

    Note: Implement methods within the database classes itself for some of these statistics; e.g. in Movie class implement methods

    public int matineeVisitors()
    public int eveningVisitors()