Note: This lab is not graded
As we discussed in lecture, files can be a very useful as a way to input data into a program and to store the output of program execution. Arrays can also be useful data structures in which to store and access information. In this lab you will develop a simple application that utilizes object-oriented programming, Java arrays and a Java text file. The idea is as follows: You will implement a very primitive database of movies. Initially, the database will be read into the program from a text file. Then, through the program you will be able to search for a movie, add a movie, show the complete list of movies, or quit the program. When you quit the program the list of movies will be saved back to the file.
We discussed in lecture how an ArrayList can be utilized to store / manipulate a collection of objects. In this lab you will implement yourself some of what an ArrayList does for you. It is a good way to see how to implement these operations and also why having an ArrayList already implemented for us is a very useful thing.
Lab Exercise
Most of this lab has been written for you, with comments. Read over the code and the comments carefully, so that you understand what is being done. Note especially how the Movie class and the MovieDB class have been set up. Note also the movieFile.txt data file, so you understand how the data is to be formatted. Your task is to complete the sections of code that have been omitted from the main program so that it works correctly. Ask your TA if you need help.
Here are the pertinent files:
Movie.java -- Class to
represent a Movie. This has already been completed for you, but read the
comments carefully.
MovieDB.java-- Class to
represent a simple database of Movies. This also has been completed for
you, but again read it carefully to see how it implements the various
operations
Lab7.java-- Main program class. Much of this has
also been implemented, but you must complete 3 sections to get it to work
movieFile.txt-- Example file used for the program
output.txt-- Demo runs to show how program should work