MCS-177 Project 9: Music Library (Spring 2016)

Start: Thursday 5/5; Due: Friday 5/13, by the beginning of class


Overview

In this project, you will experiment with building your own Python classes. Many of you have music files on your computer and organize them into playlists. You will build classes to represent your music files and playlists to organize them.

You may do this project with a partner. If you choose to work with a partner, please only submit one copy of the code with both names written in each of the Python files as a comment.

Specific tasks

  1. Implement the Song class in song.py such that:

  2. Implement the Playlist class in playlist.py such that:

  3. Make at least two sample playlists, each with at least 3 songs, by placing appropriate assignment statements in sample.py. (Make sure there are at least 5 unique songs in your examples.)

Having fun with your songs and playlists

NOTE: This only works on Macs (Mac OS X).

  1. Place all your Python files (song.py, playlist.py, and sample.py) and your MP3 files that you used in the samples in the same directory.
  2. Download play.py into the same directory.
  3. Open Terminal by typing "Terminal" (without quotation marks) in Spotlight (the magnifying class at the top right corner of the screen).
  4. Navigate to the directory where you have all your files using the command cd.
  5. Type python to enter the Python shell.
  6. Type from play import * into the Python shell.
  7. Type play(myPlaylist1) into the Python shell (or any other playlists you created in sample.py), and enjoy your music!
  8. You can press ctrl-c (CTRL key and C key at the same time) to stop playing the playlist.

Submitting your work

You will be submitting your code using Moodle; click on the following link for instructions on submitting code using Moodle. For this project, you will need to submit the following files:

Grading

You will earn one point for each of the following accomplishments:

  1. You have all the instance variables necessary for the Song class.
  2. You have accessor methods for all the specified instance variables in the Song class.
  3. You have mutator methods for all the specified instance variables in the Song class.
  4. The mutator methods in the Songclass respond to a blank string by printing an error message and not changing the instance variable.
  5. The Song class provides a special method such that you can convert a Song object into a string, which would aautomatically be used for printing.
  6. You have all the instance variables necessary for the Playlist class.
  7. You have accessor methods for all the specified instance variables in the Playlist class.
  8. You have mutator methods for all the specified instance variables in the Playlist class.
  9. The name mutator method in the Playlistclass responds to a blank string by printing an error message and not changing the instance variable.
  10. The Playlist class provides a special method such that you can convert a Playlist object into a string, which would be automatically used for printing.
  11. The nextSong method returns a Songobject.
  12. The nextSong method returns the correct Song object when the Playlist is set to non-random order.
  13. The nextSong method returns the correct Song object when the Playlist is set to random order.
  14. The nextSong method does not return the same Song object until all Song objects have been returned by the nextSong.
  15. You wrote the correct contract for each accessor method in the Song and Playlist classes.
  16. You wrote the correct contract for each mutator method in the Song and Playlist classes.
  17. You wrote the correct contract for the nextSong method in the Playlist class.
  18. Your code is not unneccessarily complex.
  19. You construct at least 5 Song objects in sample.py.
  20. You construct at least 2 Playlist objects with different names and songs in sample.py.