Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

make a program that manages a collection of DVDs (Lists title, category, running

ID: 3600381 • Letter: M

Question

make a program that manages a collection of DVDs (Lists title, category, running time, year, and price). List of DVDs and info for each are stored in a text file before and after the program is executed.

DVDCollection.txt

Interface

write the code for one interface (DVDCollectionInterface) and three classes (DVD, DVDCollection, and DVDApplication), for which the details are given below. Interface DVDCollectionInterface - The interface file for the DVD collection. This interface should include the following methods:

LoadData – this method should have a file name as the parameter. The method loads the data containing the DVD collection entries from a given file. Search – this method should have a DVD title as the parameter. It should return the DVD entry if found, or null if not found. Add – this method is used to add a new DVD. It should have five parameters that represent the title, category, running time, year, and price of a DVD. If the title is already in the DVD collection, there is no need to add or change anything. Otherwise, the DVD is added to the collection. It returns the DVD entry if it is already in the DVD collection, or returns null if a new one is added. Remove – this method should have a title as the parameter. It should remove the DVD from the collection if the title is found. It returns the DVD entry which was removed, or returns null if the title is not found. DisplayDVDsInCategory – this method should have a category as the parameter. It should return an arrayList object with all the DVDs in the specified category. If there is no DVD in the given category, the size of the arrayList will be zero. Save – this method has no parameter. It should write the DVD collection back to the file (the same file is used for both reading and writing). Please include detailed comments for all the methods in the interface (and in classes).

Classes

DVDApplication - The class for the main program. You will need to read the data from input file, display menu options, and perform various tasks that user selects. DVDCollection - The class for the actual DVD collection. The DVD collection need to have an ArrayList object and possibly other variables, such as the input file name and a boolean variable to indicate whether the directory has been modified. You will need to write the code for all the methods specified in the DVDCollectionInterface. You may add additional methods as needed to this class, however ALL additional methods you add MUST be declared as private. DVD - The class containing all of the information about one DVD. The information to be stores is: the title of the DVD, the category for the DVD, the running time for the DVD (use String type for the running time), the year the DVD was released, and the price paid for the DVD. You should include get methods for ALL five of the data fields. You should include set methods for all of the data fields EXCEPT title. The title of the DVD is not allowed to be changed. You will need to write the code for the toString method. You will need to write the code for the equals method. This method should have one parameter of Object type. Two DVD objects are considered to be equal if they have the same titles. You will need to write the code for the compareTo method. This method should have one parameter of Object type. This method is to test the order of two DVD objects to see which one comes first alphabetically by their titles. Note that in order to have this method, your DVD class should implement the Comparable interface.

Program Requirements

As your program begins, it should read previously saved data from a file. The name of the file will be DVDCollection.txt. The data in the file should be in the following format; i.e. each piece of data should be on a separate line - title on the first line, category on the second line, running time on the third line, year of release on the fourth line and price on the fifth line. The input file contains information for multiple DVDs in the above format. A sample input file is posted on Blackboard. (While you can use this sample input file to test your program, the instructor may not necessarily use it to test your programs.) The program should then display a menu of options to the user and allow the user to make choices from the menu. This continues until the user selects the exit option from 3 the menu. Upon exiting, the program should save the DVD collection back to the file if any of it has been modified.

Menu Options

Add new DVD entry - the user should be able to add new DVDs to the collection. First ask user to enter the title. Check whether the title is already in the collection. If so, display a message and return to the main menu. Otherwise, ask user to enter the rest four pieces of information associated with a DVD, and add the new DVD to the collection. Look Up DVD Entry - the user should be allowed to look up the data for a DVD in the collection. Ask the user to enter a DVD title. If the title is not in the collection, display a message to the user stating that the item is not in the collection. If the title is found, display all of the data associated with the requested title - one item per line. Make sure to label each item as it is displayed. Display DVDs By Category - the user should be able to display all DVDs in a particular category. Ask the user to enter a DVD category. If there are no DVDs in the collection matching the requested category, display a message to the user stating that there are no DVDs in the requested category. Otherwise, display a list of DVD titles - one title per line - for the DVDs in the specified category. Display only the titles, and not all of the information. Remove DVD Entry - the user should be allowed to remove a DVD from the collection. Ask the user to enter a DVD title. If the title is not in the collection, display a message to the user stating that the item is not in the collection. If the title is found, display all of the data associated with the requested title - one item per line - along with a message that the DVD has been removed from the collection. Save Data - the user should be allowed to save the DVD collection back to the file. The save option should not actually do anything if the collection has not been modified. Exit – exit the program. Upon exiting, the program should save the DVD collection back to the file if any of it has been modified.

Sample Input

File A sample input file (DVDCollection.txt) will be posted on Blackboard. Please do not change the file name in your source code.

Explanation / Answer

toString - returns a string containing all of the DVDs in the collection, separated by newlines characters, along with the value of numdvds and the length of the DVD array for debugging purposes. The string should be formatted as shown in the example below:

addOrModifyDVD - given the title, rating and running time of a DVD, add this DVD to the collection if the title is not present in the DVD collection or modify the DVD's rating and running time if the title is present in the collection. Do this operation only if the rating and running time are valid. If a new DVD is added to this collection, insert the DVD so that all DVDs are in alphabetical order by title. (NOTE: The collection should already be in alphabetical order when this method is called since this is the only method available to insert DVDs.)

removeDVD - given the title, this method should remove the DVD with this title from the collection if present. The title must match exactly (in uppercase). If no title matches, do not change the collection.

getDVDsByRating - given the rating, this method should return a string containing all DVDs that match the given rating in the order that they appear in the collection, separated by newlines.

getTotalRunningTime - this method should return the total running time of all DVDs in the collection. If there are no DVDs in the collection, return 0.