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 are to do this project with a partner (but exceptions will be granted if you strongly prefer to submit an individual project).
If you work with a partner,
please only submit one copy of the code with both names and email addresses written in each of the Python files as a comment at the top of the files.
Please also write both partners' names and email addresses on the comment box on Moodle.
Else, if you submit an individual project, please state that clearly at the top of your Python files as well as the comment box on Moodle.
sort.Song class in song.py such that:
Song object contains the artist, album title, song title, mp3 file name, and genre.
Song class provides accessor and mutator methods for all instance variables.
Song object is printed, it shows the artist, album title, and song title. For example, if you print the song "Just Dance" in The Fame by Lady Gaga, you should see:
Just Dance in The Fame by Lady Gaga
Playlist class in playlist.py such that:
Song objects, and an indication whether the playlist is to be played in a random order.
Playlist class provides accessor and mutator methods for the instance variables you use for the name, list of songs, and random-play indication.
Playlist object is printed, it shows the playlist name and all the songs in the playlist. For example, if you print the playlist whose name is "Lady Gaga Mix" and which contains two songs: "Just Dance" in The Fame by Lady Gaga and "Americano" in Born This Way by Lady Gaga, you should see:
Playlist: Lady Gaga Mix
Just Dance in The Fame by Lady Gaga
Americano in Born This Way by Lady Gaga
Playlist class provides a method called nextSong which returns the next Song object to play in the playlist. If the playlist is played in the original order, it should return the next song in the list. If the playlist is played in a random order, it should return a song that has not been played yet. It should only repeat a song if all songs in the playlist have been played. This ensures that the playlist does not keep returning same two songs over and over again.Notes and considerations
nextSong method should return the first song in the original list of songs. If the play order is changed from non-random to random, it should start returning songs in a random order as described above.
nextSong method should return the first song in the new list of songs. If the player order is random, it should return a random song in the new list of songs.Example of a playlist of 3 songs (A, B, C)
| Non-random order | Random Order | ||
| Correct | Incorrect | Suspicious | |
|
Song A Song B Song C Song A Song B Song C Song A Song B Song C . . . |
Song C Song B Song A Song B Song A Song C Song C Song A Song B . . . (Notice how each song appears only once in songs 1-3, 4-6, etc.) |
Song C Song B Song C Song A Song B Song A Song B Song C Song A . . . (Notice how Song C reappears before all 3 songs are played.) |
Song B Song C Song A Song B Song C Song A Song B Song C Song A . . . (Notice how the same permutation (B, C, A) keeps repeating.) |
shuffle or
randint function within the random module or use other methods to accomplish this task.
sample.py. (Make sure there are at least 5 unique songs in your examples.)
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:
Song class.Playlist class.You will earn one point for each of the following accomplishments:
Song class.
Song class.
Song class.
Song class respond to a blank string by printing an error message and not changing the instance variable.
Song class provides a special method such that you can convert a Song object into a string, which would automatically be used for printing.
Playlist class.
Playlist class.
Playlist class.
Playlist class responds to a blank string by printing an error message and not changing the instance variable.
Playlist class provides a special method such that you can convert a Playlist object into a string, which would be automatically used for printing.
nextSong method returns a Songobject.
nextSong method returns the correct Song object when the Playlist is set to non-random order.
nextSong method returns the correct Song object when the Playlist is set to random order.
nextSong method does not return the same Song object until all Song objects have been returned by the nextSong.
Song and Playlist classes.
Song and Playlist classes.
nextSong method in the Playlist class.
Song objects in sample.py.
Playlist objects with different names and songs in sample.py.