lab04 : Music Library

num ready? description assigned due
lab04 true Music Library Mon 05/06 08:00AM Sun 05/19 11:59PM

Goals

For this lab, the focus will be on writing an music organization application utilizing Interfaces, Inheritance, and Polymorphism concepts. The application will read music data from a text file into the program, organize the information, and output the information to files according to the specification.

Pair Programming

This lab may be done solo, or in pairs.

Before you begin working on the lab, please decide if you will work solo or with a partner.

As stated in previous labs, there are a few requirements you must follow if you decide to work with a partner. I will re-iterate them here:

Once you and your partner are in agreement, choose an initial driver and navigator, and have the driver log into their account.

Instructions

Music Library applications (i.e. iTunes, Windows Media Player, etc.) organize music data that allows users to search, sort, and play songs in their library. This application is used more to organize and archive a music library of various music track formats. We obviously won’t cover all functionality in a full-featured music library, but we will write an application that is able to read music data from a text file (either on your local hard drive or on the web), and organize the data such that it will be easy to display the entire contents of the imported library based on artist and song names.

You will implement a simple User Interface that prompts the user to read a predefined file containing information on various Music Tracks (MusicList.txt) on your local hard drive or from the web. Your program will use inheritance and polymorphism to organize your code in order to differentiate two types of music tracks: Digital or Vinyl (we can obviously extend this to many types of formats, but for this lab we will assume these are the only two formats that will be imported), and write the music track data to specific output files.

A MusicList.txt file will contain multiple music track data in a fixed format. All pieces of the music track data will be separated by a ;. For a digital music track, the format will look as follows:

(Track_title);(Track_length);(Artist);(Album);(Release_date);(Format_Type);(BitRate)

For a vinyl music track, the format will look as follows:

(Track_title);(Track_length);(Artist);(Album);(Release_date);(Format_Type);(RPM)

The only difference between a digital music track will be the Format_Type- a D value implies the track is in a digital format and a V value imples the track is in Vinyl format. For digital music tracks, the BitRate value is the encoding used for the track. For vinyl music tracks, the RPM is the rotations per minute that the track was designed to be played on.

The overall flow of execution in your program will:

Console UI Example

The following output is an example of how a user will interact with your application (user input is in bold) and comments are not part of the output but used for context:

Welcome to the Music Library Application!
Enter `D` to read the music file from your local disk or `W` to read the music file from the web: Q
Invalid Input.
Enter `D` to read the music file from your local disk or `W` to read the music file from the web: wrong
Invalid Input.
Enter `D` to read the music file from your local disk or `W` to read the music file from the web: w
// reads MusicList.txt from the web.
Enter `A` to output tracks by Artists or `T` to output tracks by Title. Enter `Q` to quit: wrong
Invalid Input.
Enter `A` to output tracks by Artists or `T` to output tracks by Title. Enter `Q` to quit: A
// Generates artistOutput.txt
Enter `A` to output tracks by Artists or `T` to output tracks by Title. Enter `Q` to quit: t
// Generates titleOutput.txt
Enter `A` to output tracks by Artists or `T` to output tracks by Title. Enter `Q` to quit: q
// Quits application

Code Organization

You will be able to implement your program satisfying the specifications above, but there will be some requirements you must follow:

Lab04.java

MusicManager.java

MusicTrackInterface.java

MusicTrack.java

DigitalTrack.java

VinylTrack.java

BucketInterface.java

ArtistBucket.java

TitleBucket.java

OutputFileInterface.java

OutputFile.java

Possibly some useful tools

You will probably find the String method compareTo() quite useful. s.compareTo(t), with s and t being Strings, returns 0 if s and t have the same value, a number less than 0 if s comes before t in alphanumeric order, and a number greater than 0 if s comes after t. This method comes in handy when figuring out where to place a music item in the music list so that ordering by title is maintained.

You will also probably find the String method split(delimiter) quite useful. split returns an array (of type String) with each cell containing the substring that is terminated by the given delimiter, or by the end of the string; they are placed in order in the array. So, if you have, say, a string “This is a sentence.” stored in aSentence, String[] words = aSentence.split(“ “) will return words[0] = “This”, word[1] = “is”, word[2] = “a” and word[3] = “sentence.” - a handy method for breaking up the Music Track lines into appropriate values.

Also, note that characters are actually numerical values that can be subtracted from other characters. One handy way to calculate which ArrayList index a specific Artist name or Track Title should go into is by extracting the first character from the name is:

Character.toUpperCase(string.charAt(0)) - 'A'

For the example, a or A will return an index 0, b or B will return an index 1, etc.

Testing

For this lab, you may use the given MusicList.txt file and the resulting output to confirm the correctness of your program. You may also create your own MusicList.txt files to test the edge cases (duplicate artist / title names) to make sure your ArrayLists are sorted properly.

I do expect students to practice writing unit tests for this lab, but will keep the requirements flexible so everyone can think and explore which tests are important in order to satisfy the specifications. The test file should contain JUnit tests named MusicLibraryTests.java.

At the very least it’s a good idea to check if the artist / title buckets are functioning correctly (storing digital / vinyl music tracks into the buckets as well as keeping the music tracks in sorted order according to the specifications), and if music track information is displayed in the correct format.

Submitting to Gradescope

The lab assignment “Lab04” should appear in your Gradescope dashboard in CMPSC 56. If you haven’t submitted anything for this assignment yet, Gradescope will prompt you to upload your files.

Remember to add your partner to Groups Members for this submission on Gradescope if applicable. Please include both names and PERM numbers for each submitted file. At this point, if you worked in a pair, it is a good idea for both partners to log into Gradescope and check if you can see the uploaded files for Lab03.

For this lab, you will need to upload all of your .java source files as well as MusicList.txt:

NOTE: Please be sure to ONLY submit the .java files and MusicList.txt in order to help our TAs streamline grading. DO NOT include additional files (such as .class files). Also, DO NOT put your files into any subdirectories or define specific packages when submitting your files to Gradescope.:

You either can navigate to your files, “drag-and-drop” them into the “Submit Programming Assignment” window, or use your private GitHub repo to submit your work (if you do this, be sure that your repo ONLY contains the .java files and doesn’t have any .java files in sub directories).

If you already submitted something on Gradescope, it will take you to their “Autograder Results” page. There is a “Resubmit” button on the bottom right that will allow you to update the files for your submission.

Most of the programming assignments for this class will not be autograded in the same way you may have seen in earlier courses. We will use Gradescope mainly as a “dropbox” for all of your assignments. Our staff will manually grade your assignments and assign a score to your submission.

Since Gradescope autograding is disabled, it is very important for you to test and compile your code locally according to the specifications of this lab. As a software developer, it’s an important skill to think of correct functionality and test cases on your own. Be sure to do this before submitting your code to Gradescope. If our staff cannot run your code, then you will receive a 0 for this assignment (and this will not be apparent when submitting your code since Gradescope will not actually compile your code for this assignment).

Your submission will initially have a score of 0.0/100. Don’t worry - this is normal. Once the assignment has been graded by our staff, your actual score will be updated.

Adapted and modifed from Norm Jacobson’s A Donation to the Music Archive ICS45J lab for CS56 S19.