CS 261 Homework 1 - Movie Library
Due Wed Jan 30 at 9:00am
Overview
This assignment will help you refresh your Java basics, while giving you experience working with the Eclipse IDE. Your task is to write a pair of Java classes that together manage a simple movie library. This library will be usable through the command-line, using menus such as the one below:
Welcome to the movie library. Select an option: 1. Load a library 2. List movies in library 3. Look up a movie by title 4. Add a movie to the library 5. Remove a movie from the library 6. Look up an artist (director / actor) 8. Save movie library 9. Exit system >This assignment should be completed individually.
Objectives
- To review some topics from CS 161
- To practice organizing and developing projects from scratch.
- To practice using ArrayLists, the Scanner, and basic searching algorithms
- To practice reading and producing code documentation
- To become more familiar with the Eclipse IDE
Necessary Files
You will need a copy of the
Hwk1.zip file
which contains the Movie.java
class, the README.txt for the assignment (see below), and a small example movie library.
Details
- Read through all of these instructions carefully before you begin!
- Your task is to create a simple program that manages a library of movies (like a person's home video collection). This program will allow users to load a list of movies from a file, search through the list, add or remove items from the list, and then save the list back to a file. Users will interact with the system through the command-line.
-
I have provided you with a
Movie
class that represents a film. Create a new Eclipse project and import this class (see Lab A). Look through the code and its documentation to get a sense for how it works. This class will form the basis for your library. Note that I have includedstatic
methods that will read and write a list of movies to a file. You should take a few minutes to make sure you understand how they work (they use the Scanner class, and so can also be looked at as a demonstration of that).- The first thing you'll want to do is add a
toString
method to the Movie class, to make it easier to display the movies and debug your program. Remember that the method signature of such a method ispublic String toString()
. - You should not need to make any other changes to the Movie class! Be sure to document any changes you make in the README.
- The first thing you'll want to do is add a
-
You will need to create three new classes for this program, detailed below:
MovieLibrary
: This class represents your movie library (your list of movies). It should be a relatively simple class to create. It should contain at least the following methods:-
void addMovie(Movie movie)
: Adds a movie to the library. Be sure to check for duplicates! -
void addMOvies(ArrayList
: Adds a list of movies to the library. Be sure to check for duplicates!movies) -
void removeMovie(Movie movie)
: Removes a movie from the library. -
Movie findMovie(String title)
: Searches the list for a movie with a particular title, and returns that movie. -
ArrayList
: Searches the list and returns all movies who contain a particular artist. Note that the artist can be either an actor or a director (or, like Clint Eastwood, both!)findArtist(String artist) - You may also want to make
load()
andsave()
functions, though see below.
The bulk of your logic for dealing with the library of movies should be in this class.
MovieLibraryManager
: This is your "interaction" class--the class that handles the logic for the menus and allows the user to pick what actions to perform on the list. You will likely want to have amainMenu()
method that, while the user is still using the database shows the main menu and lets the user pick an action to perform. Each action they pick can be associated with a helper method; these helper methods may prompt the user for extra information, call further methods, etc. Thus you will want helper methods for at least the following uses:-
loadLibrary()
: loads a text file of movies (a library). Note that this method, like most the ones you will write, will interact with specific methods in the MovieLibrary class. Think about what steps for loading a library are more appropriate to be in the Library class and which are more appropriate to be in the Manager class, so that you can have the best level of cohesion and coupling. -
saveLibrary()
: saves the list of movies to a text file. See above note. -
listMovies()
: prints a listing of all the movies to the screen (hint: a carefully written toString() method for the Movie class should make this trivial!) -
lookUpMovie()
: allow the user to enter a title and get information about that title. -
addMovie()
: allow the user to specify a new movie. Note that the user will need to enter a variety of information, such as the new movie's title and list of actors. Think about what the interaction will be before you start writing this! -
removeMovie()
: allow the user to remove a movie from the list. They will need to look up the movie first (likely by title)---can you reuse code that you've already written for that? Also, be sure to have the user "confirm" deleting a movie. -
lookUpArtist()
: Allow the user to search for a list of movies that contain a particular artist (see above).
Users of course should also be able to exit the system.
You can get input from the user through the Scanner class (described on page 662--64 in the book).
MovieLibraryManagerTester
: This is your tester class that contains your main method. It should create a new MovieLibraryManager and start the main menu. Remember, most of the interaction logic should be in your LibraryManager; the tester class just starts things up! -
-
Think through how you will organize and complete each methods before you begin. It may seem like a lot of functionality, but each method is fairly simple (and similar to what you did in 161). If you get stuck, come and see me!
- That said, this isn't a SMALL amount of work. Get started early!!
- Be sure that all your code is fully documented. This means Javadoc comments on each method you create, and lots of comments explaining your code. Remember to explain the why of the code, not the what.
- Finally, be sure to complete the README.txt that you found in the Hwk1.zip file, and upload it along with your code!
Submitting
BEFORE YOU SUBMIT: make sure your code is fully documented and functional! If your code doesn't run, I can't give you credit!
Submit your program to the Hwk1 submission folder on hedwig, following the instructions detailed in Lab A. You should upload Movie.java, MovieLibrary.java, MovieLibraryManager.java, MovieLibraryManagerTester.java, and the README.txt. Feel free to upload any movie lists you create as well!
The homework is due at the start of class on Wed Jan 30.
Extensions
Although not a requirement for this assignment, you might consider adding the ability for users to get a list of recommended movies. How you recommend a movie is up to you: maybe you recommend movies that are highly rated; maybe you recommend movies that have the same artists as movies that are highly rated; maybe you recommend a movie that is highly rated but hasn't been seen (played) very often.
There are a large number of other functions you could add to this system: the ability to modify movies, to add or remove actors, to sort films by some criteria (or multiple criteria), or to track other information such as the run-time or box office receipts.
Grading
This assignment will be graded based on approximately the following criteria:
- Program includes the seven listed user functions (~10% each)
- Program demonstrates proper cohesion and coupling, in accordance with good style (15%)
- Program is fully documented (10%)
- README is completed (5%)