COMP1400 – Programming for Designers

Class announcements for Programming for Designers

COMP1400 – Programming for Designers random header image

Assignment 2 – ArrayList

Posted by on September 8th, 2014 · 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 21 September 2014)

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 atone.
    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 instructions

You will submit your assignment to the Give automated marked system.

  1. From within your assignment 2 BlueJ project, select Project -> Create Jar File…
  2. In the Dialog Box that appears:
    1. Set “Main Class” to none
    2. Ensure “Include Source” is checked
    3. Leave “Include Bluej project files” unchecked
  3. Press “Continue”
  4. Save the filename as “Assignment2.jar”
  5. Open a web browser and go to the give web site
  6. Log-in with you Z-Pass
  7. Either enter “COMP1400″ in for the course, or select COMP1400 from the drop down menu and press “Search for Assignments”.
  8. Select “assignment2″ from the next drop down menu and press “Upload my Assignment”
  9. Accept the student declaration
  10. Press “Choose File” and select the “Assignment2.jar” file that you saved in step 4
  11. Press “Submit my Files”
  12. Wait for the page to completely load. Then carefully read the output. If the assignment is successful you should see the following lines:
    ================================================
    Checking your submission...
    
    Checking for PlayList.java
    PlayList.java Compiled Successfully
    Checking for Track.java
    Track.java Compiled Successfully
    
    All files are OK
    ================================================
  13. If the page doesn’t load properly, that is OK just submit the assignment file again.
  14. If you don’t get the above output check the output to see what went wrong and resubmit.

Submission notes:

  1. You can submit as many times as you wish, even after the deadline. Only your last submission will be marked.
  2. Make sure you name everything the as instructed, including the classes and the submission file or the submission will not work.
  3. If you have any problems with submission, email the class account

 

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.