diff --git a/hws/spotify_playlists/README.md b/hws/spotify_playlists/README.md index 1c77737..0002c82 100644 --- a/hws/spotify_playlists/README.md +++ b/hws/spotify_playlists/README.md @@ -35,7 +35,7 @@ The following images show the behavior of pressing "Next". Before pressing "Next", the currently playing song is "Always Remember Us This Way": ![alt text](images/before_press_next.png "Spotify before pressing next") -Press "Next" +Press "Next": ![alt text](images/press_next.png "Spotify pressing next") After pressing "Next", the currently playing song is now "Million Reasons": @@ -46,7 +46,7 @@ The following images show the behavior of pressing "Previous". Before pressing "Previous", the currently playing song is "Million Reasons": ![alt text](images/before_press_previous.png "Spotify before pressing previous") -Press "Previous" +Press "Previous": ![alt text](images/press_previous.png "Spotify pressing previous") After pressing "Previous", the currently playing song is "Always Remember Us This Way": @@ -54,10 +54,76 @@ After pressing "Previous", the currently playing song is "Always Remember Us Thi ## Command Line Arguments -Your program will support 5 commands. +Your program will be run like this: -### Command 1: add a music track to a playlist -The first argument is the name of an input file which contains a playlist. The second argument is the name of another input file which contains all available music tracks. The third argument is the output file. The fourth argument is the action, which in this case is "add". The fifth argument is the title of the music track. +```console +./nyplaylists.exe playlist.txt actions.txt output.txt +``` + +Here: + +- nyplaylists.exe is the executable file name. +- playlist.txt is the name of an input file which contains a playlist - in this README, we will refer to this file as the **playlist file**. +- actions.txt is an input file which defines a sequence of actions - in this README, we will refer to this file as the **actions file**. +- output.txt where to print your output to. + +## Playlist File Format and Output File Format + +The playlist file and the output file have the same format. Take the playlist_tiny1.txt as an example, this file has the following 4 lines: + +```console +"Perfect Duet" Ed Sheeran, Beyonce +"Always Remember Us This Way" Lady Gaga current +"Million Reasons" Lady Gaga +"I Will Never Love Again - Film Version" Lady Gaga, Bradley Cooper +``` + +Except the second line, each line has two fields, the music title, and the artist(s). There is one single space separating these two fields. + +The second line is special, it ends with the word **current**, meaning that the song "Always Remember Us This Way" is the currently playing song. This word **current** appears in the **playlist file** once and should also appear in the output file once. + +## Actions File Format + +The actions file has a defines actions. Take actions1.txt as an example, this file has the following lines: + +```console +add "Umbrella" Rihanna +add "We Are Young" Fun +add "You Are Still the One" Shania Twain +remove "Million Reasons" Lady Gaga +add "Viva La Vida" Coldplay +move "I Will Never Love Again - Film Version" Lady Gaga, Bradley Cooper 1 +next +next +next +previous +move "You Are Still the One" Shania Twain 4 +``` + +The **actions file** may include 5 different types of actions: + +- add, which adds a song to the playlist. +- remove, which removes a song from the playlist. +- move, which moves a song to a new position - the new position is always included at the end of the line. The line *move "I Will Never Love Again - Film Version" Lady Gaga, Bradley Cooper 1*, moves the song "I Will Never Love Again - Film Version" to position 1, and the line *move "You Are Still the One" Shania Twain 4*, moves the song "You Are Still the One" to position 4. Note that, unliked array indexing in C/C++, positioning in Spotify starts at 1, as opposed to 0. This can be seen in the above Spotify screenshot: the first position is position 1. +- next, which skips the currently playing song and starts playing the song that is listed directly after it. +- previous, which skips the currently playing song and goes to the song listed directly before the currently playing song. + +According to this sample **actions file**, 4 songs will be added to the playlist, 1 song will be removed, 2 songs will be moved. And the currently playing song will be a different song, instead of the song "Always Remember Us This Way". + +When playlist_tiny1.txt and actions1.txt are supplied to your program as the two input files, your program should produce the following output file: + +```console +"I Will Never Love Again - Film Version" Lady Gaga, Bradley Cooper +"Perfect Duet" Ed Sheeran, Beyonce +"Always Remember Us This Way" Lady Gaga +"You Are Still the One" Shania Twain +"Umbrella" Rihanna +"We Are Young" Fun current +"Viva La Vida" Coldplay +``` + + ## Handling Music Tracks with the Same Title