COMP1400 – Programming for Designers

Class announcements for Programming for Designers

COMP1400 – Programming for Designers random header image

Assignment 2

Posted by on August 23rd, 2011 · Assignments

Your second assignment will test your ability to use lists. Your task will be to implement a class representing a playlist from a music program like iTunes.

Due Date: Sunday week 8 (23:59:59 18 September 2011)

Download the ass2.zip file to get you started. It contains three classes:

  • Track – This class represents a single track with a name, a genre (from a list of constants on the class) and a duration (in seconds). Do not modify this file.
  • PlayList – This is the class you are to complete. I have given you the headers for all the methods you need to implement.
  • PlayListTest – This is a JUnit testing harness for your code. At the moment it provides only three tests. You should add more tests to this class to make sure your code works correctly.

Note: You will only be marked on your modifications to the PlayList class. The PlayListTest class is there to provide you with some example tests to check your code is working. You should add your own tests to this class, but you will not be marked on them.

Requirements

A PlayList is a container for Tracks. It provides the following functionality:

  • Two constructors:
    1. The first constructor simply asks for a name for the list and creates an empty playlist
    2. The second constructor asks for a name and a list of tracks. It creates a playlist and copies the tracks from the list (in order) onto the playlist.
  • Accessor methods:
    1. getName – returns the name of the playlist
    2. getDuration – returns the total duration of all tracks on the playlist
    3. getNumberOfTracks – returns the number of tracks on the playlist
    4. getTrack – returns the specified track. Tracks should be numbered starting at one.
    5. filterByGenre – get the list of tracks from the playlist (in order) that match a given genre.
  • Mutator methods:
    1. addTrack – add a track to the playlist
  • Display methods:
    1. printListing – print out the name of the playlist and a numbered listing of all tracks on the playlist

The formatting of the printListing method should look like the following:


Queen's Greatest Hits
1: Bohemian Rhapsody - 5:54
2: Another One Bites The Dust - 3:34
3: Killer Queen - 3:01
4: Fat Bottomed Girls - 3:22

You can use the toString() method on the Track class to get the title and duration in a appropriately formatted string.

Sample solution

There is a sample solution (with source code removed) available to download. If any part of this specification is unclear, check the sample solution and reproduce its behaviour as closely as possible.

Marking

Marks will be awarded as follows:

  • Constructors and accessor methods (except filterByGenre) – 25%
  • addTrack – 15%
  • filterByGenre – 15%
  • printListing – 15%
  • Style – 30%

If the assignment is submitted late, 10% will be taken off the maximum mark per day, to a maximum of 5 days.

Submission

The due date for submission is 11:59pm Sunday September 18.

You will be submitting your solutions online, by the following steps:

  1. Select “Create Jar File…” In the Project menu in BlueJ.
  2. In the dialog box make sure the “Include source” box is checked.
  3. Press Continue
  4. Save with the filename “ass2.jar
  5. Go to https://cgi.cse.unsw.edu.au/~give/Student/give.php
  6. Login with your CSE username and password
  7. Type COMP1400 in the Course field and press Search
  8. Select ass2 from the list of assignments and press Upload my assignment
  9. Select Browse to locate your ass2.jar file.
  10. Press Submit my files.
  11. Check the response to make sure your submission was processed correctly.

NOTE: You can submit as often as you like. Only the last submission will be marked. Do NOT leave it to the last minute. No sympathy will be given if you leave submission until midnight Sunday and something goes wrong. It is good practice to make multiple submissions as you go.

No Comments so far ↓

There are no comments yet...Kick things off by filling out the form below.

You must log in to post a comment.