Homework 7: Music Library
Due December 2 @ 8:00pm on Autolab
1. Introduction
In this assignment, you’ll be writing the code for a music manager. We don’t specify which data structures you should use to store the information about your songs, but we do specify efficiency requirements for various pieces of functionality. These efficiency requirements should guide your choices of data structures.
You are given a plain text file of songs (there are multiple examples in the pre-prepared Eclipse project, such as tunes.txt
). Each song entry in the file is formatted in the following manner:
- artist
- title
- album
- genre (1 word), followed by any playlists the song is contained in (could be 0), each separated by a semi-colon (;) (every song belongs to exactly one genre, but can belong to zero, one, or more playlists)
- a blank line to separate entries (warning: there is no blank line after the last entry!)
Download a pre-prepared Eclipse Project hw7.zip
and import it into Eclipse using these instructions. You will make all of your changes inside of the Java files in this project.
2. Your Tasks
You have three main tasks.
- Finish the
Song
class. - Finish the
MusicLibrary
implementation with all of the requested methods. - Write a
MusicLibraryManager
that provides a text based interface for managing a music library.
2.1. Finishing the Song
class
You need to write a class to contain the information about an individual song.
A song object stores information about an individual song. A song will have, at least: An artist, title, album, and genre. Two songs are considered to be the same song if exactly those four things are the same. You will also need some way to keep track of which playlists a song is on.
You can decide on your own design for this class, but it must at least have
the specified constructor and a correct toString(). You will also certainly
need to add more methods to it. You will likely need to override both equals
and hashCode
, depending on how you store your data.
The toString()
for this class should produce results such as…
Song [artist=Johnny Cash, title=If I Told You Who It Was, album=Out Among The Stars, genre=outlaw country, playlists=[]]
Song [artist=Johnny Cash, title=If I Were a Carpenter, album=Hello, I'm Johnny Cash, genre=outlaw country, playlists=[]]
Song [artist=Johnny Cash, title=I Won't Back Down, album=American III: Solitary Man, genre=arkansas country, playlists=[Driving Music]]
Song [artist=Diana Haddad, title=Ela Hona, album=Ela Hona, genre=lebanese pop, playlists=[Arabic Tunes, Driving Music, Khaliji Sad Melodies]]
Note that the playlists are in sorted order. That is intentional and required.
2.2. Finish MusicLibrary
The MusicLibrary
class is the core of this homework. It contains a variety of methods that you need to write that are all involved in
managing songs. Many of the methods have specific efficiency requirements that your implementation must meet.
Before you jump into writing code for this class, you should carefully plan what data structures you will use to store which data, ensuring you know how you will meet the efficiency requirements. If you don’t plan this properly, then you may end up needing to rewrite large parts of the homework in order to meet the efficiency requirements.
Check the documentation inside of MusicLibrary.java
for details regarding the methods you need to write the efficiency requirements they have. Pay careful
attention to how the efficiency requirements are specified. If, for example, an efficiency requirements says: “This must be O(M), where M is the number of artists,” then your
efficiency must depend only on the total number of different artists; it cannot depend on the number of songs.
2.3. Write a MusicLibraryManager
The MusicLibraryManager
class is a text-based interface that allows a user to manage a music library. Currently, the menu lists all
of the functionality that the MusicLibraryManager
is required to provide. You need to actually provide the functionality.
Check MusicLibraryManager.java
for details.
3. Grading and Submission
There are multiple parts of the grading of this assignment:
- For the first 75 points, your submission will be auto-graded on Autolab based on your implementation of the
MusicLibrary
- For the next 15 points, your submission will be manually graded by running and testing
MusicLibraryManager
- For the next 5 points, your submission will be manually graded to check for good implementation methodologies. (Did you use a good approach to solving the problems?)
- For the next 5 points, your submission will be manually graded to check for good testcases that you include in the main method. (Do you have 2-3 basic testcases for each method, and do they all execute automatically?)
- Your code will also be checked for style. The parts of style that can be checked automatically (things like spacing, indentation, the use of CamelCase, etc.) are automatically checked by the autograder. Other parts of style, such as choosing good variable names, will be checked manually. Autograded style guide violations can result in, at most, -10 points. Manually checked style guide violations can result in, at most, -5 points.
You will submit your program to Autolab. Login to the system and you will see the homework.
For this homework you’ll need to submit a zip
file containing your code. Lucky for you, however, Eclipse can create this zip file for you. Check out these instructions. On Autolab, you’ll submit that exported zip
file. On the page that follows your submission you will see your live score (out of 90). It may take up to a few minutes for your score to appear, during that time just hit refresh in your browser. If you receive a lower score than you expect, you can click on the score to see the feedback from the autograder.
For this assignment you have 15 submissions. Use them wisely.
3.1. Testcases
In this homework we are not providing any testcases.
For MusicLibrary
you need to provide at least two testcases for each of the new methods. At least one of those must be non-basic. All of your testcases should be in the MusicLibraryTester
class included with the skeleton code.
You do not need to write testcases for MusicLibraryManager
.
When grading, in addition to counting testcases we will also look at the quality of what you are testing.
4. Hints
- Start early. There is a lot of code here to write.
- If you want to convert a
Collection
(such as anArrayList
) to an array, consider the following example:ArrayList<String> theList = new ArrayList<String>(); theList.add("Bob"); theList.add("Fred"); theList.add("John"); String[] theArray = theList.toArray(new String[0]);
- Seriously, plan ahead on how you want to store your data. You will likely be storing multiple copies of some parts of the data in different data structures.
- Due to all of the efficiency testing, the autograder for this assignment takes longer than usual. The instructor’s solution, for example, requires around 2.5 minutes for the autograder to finish.
- Remember that your input file does not have the extra newline at the end. (And your output file shouldn’t have it, either.)
5. Important Notes
- If you have questions, please post to Piazza. The course staff, including the instructor, monitor and answer questions there.
- When posting to Piazza, if you include any code make sure your question is posted privately to the instructors, and not to the entire class.
- Do not change the names of any of the provided methods or files.
- After you submit to Autolab, make sure you check your score. If you aren’t sure how to do this, then ask.
- There is no partial credit on Autolab testcases. Your Autolab score is your Autolab score.
- Read the last bullet point again. Seriously, we won’t go back later and increase your Autolab score for any reason. Even if you worked really hard and it was only a minor error…
- You can submit to Autolab multiple times. So, after you submit you should check your score. If you lose points you can keep working and resubmit.