Mix Tape Calculator

CSc 103 Programming Project


The goal of this project is to write a Java program for the console version of the Mix Tape Calculator application.

Objectives

The objectives of this assignment are

Overview

In CSc 101 students implemented a procedural solution using the C language to the PlayList Calculator problem.  The problem specification has been enhanced to include a Swing GUI. Your job is to convert the C implementation into Java and take advantage of Object Oriented principles to create a better quality design that contains the features required by the enhanced specification.

Software Design

The instructor has written the code for the Graphical "front end" part of the application.  You are provided a JAR file containing the  MixTapeGUI class and other components of the GUI.  Your assignment is to write the "back end" components and a console user interface.

Here are the Javadoc for the instructor supplied components:
MixTapeApp
Natural

MixTapeCalc.jar contains the .class files for the instructor components in a JAR formatted file.   Don't unzip this file, add it as a custom library to your BlueJ or NetBeans project.
MixTapeCalc.jar (Updated 2014.1.22)

You must implement these modules:
Javadoc
Skeleton Code
Song
TimeDuration
MixTapeModel
MixTapeConsole
SongPool
PlayList
Song.java
TimeDuration.java
MixTapeModel.java
MixTapeConsole.java
SongPool.java
PlayList.java

Here is the C implementation of the
original problem.
playlistCalculator.c





Testing

Your components will be tested with instructor reference tests.  The reference tests are JUnit tests of your classes.  MixTapeGUI is not used in testing.

You must include the following data file with your submission as it will be used by the instructor's tests:
MilesDavis.m3u


Sample Execution
Here is the output produced by running MixTapeConsole with this user input .

You can also run the instructor's solution at Oracle of Java


Handing in Your Source Electronically
GRADING
The problem coverage is worth 70% of your score. In order to obtain 90% you also need to obtain 20/20 on the "Style/Coding" portion of the score. The last 10% of the score results from manually grading your solution to see that you followed the algorithm design guidelines.
On this project your solution must conform to the class coding standard. Your unit tests must demonstrate "statement" coverage (they cause every statement in your program to be executed.) There is a limit of 20 submissions.


Lessons Learned

Previous students made these comments after completing this assignment:

FAQ

Q: Can you give me a hint on what the constructor for MixTapeConsole does?
A: The constructor allows easy JUnit testing. Here's a tutorial video explaining the concept, and here's the code for the example project.

Q: What would you like us to do for a Quit command in the MixTapeConsole class. System.exit(0); seems to crash web cat.
A: Simply allow execution to finish the display() method normally. (Also, close the Writer).

Q: How can I force my test to throw IOException?
A: See the JUnit FAQ

Q: Should MixTapeModel do anything on it's own or does it delegate everything to SongPool and PlayList.
A: Everything is delegated except addToMix. All the other methods have exactly ONE line of code, which is a call to the appropriate method in SongPool or PlayList. The pseudocode for addToMix() is

        // IF there is room in the playlist for another song THEN
            // Move selected song to play list.
            // RETURN true;
        // END IF
        // RETURN false;

Q: Can I run the instructor GUI with my classes?
A: Yes. Open a terminal window and from your project directory issue this command:
In BlueJ:
java -cp +libs/MixTapeCalc.jar:. MixTapeGUI

In NetBeans:
java -cp lib/MixTapeCalc.jar:build/classes MixTapeGUI


Q: I don't understand why Web-CAT is reporting this compile error, it isn't even my code:
error: unreported exception IOException; must be caught or declared to be thrown
        model.loadM3U(new java.io.File("MilesDavis.m3u"));
A: Your loadM3U() method must NOT throw IOException. You have to catch it yourself.

Q: Where should I catch IOException when writing the file?
A: Since the spec doesn't require the application to inform the user about file i/o errors we can catch any IOExceptions in the same method that does the file writing and simply print a stack trace to standard out.

Q: Can I add a compareTo() method to TimeDuration?
A: No. The solution can be achieved with the existing methods. If you can't figure it out, ask the instructor for a hint.

Q: Why would my unit tests pass on my computer but fail on Web-CAT?
A: Does your computer run Windows? Heed this advice.

Q: Is there an easy way to make a zip file in NetBeans for submitting to Web-CAT?
A: Yes, add this code snippet to your build.xml file to create a "zip" target.

Q: What problems did students in previous problems have with this assignment?
A: Four categories: Tools, Specs, Testing, Time Management

Q: Do you have any examples of "algorithm" mistakes to be avoided?
A:
Don't make an instance of Vector in Playlist or SongPool.
Don't put a return inside an if statement
Don't add extra public methods
Use Scanner, not BufferedReader
And for heaven's sake, don't use recursion.


Document History

4/18/2017 Added java command for NetBeans to FAQ.
4/11/2017 Add link to Ant zip target
4/10/2017 Add items to FAQ
3/30/2017 updated for CSc 305
1/26/2014 updated FAQ
10/10/2012 Added sample console output
9/24/2009 Available for Fall 2009