Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Homework 1 Spotify Playlists Before starting this homework, make sure you have read and understood the Academic Integrity Policy. In this assignment you will develop

Homework 1 Spotify Playlists
Before starting this homework, make sure you have read and understood the Academic Integrity Policy.
In this assignment you will develop a program to manage music playlists like Spotify does, let's call this program New York Playlists. Please read the entire handout before starting to code the assignment.
Learning Objectives
Practice handling command line arguments.
Practice handling file input and output.
Practice the C++ Standard Template Library string and vector classes.
Background
On Spotify, users can create and manage playlists. On the Spotify app or website, users can navigate to the "Your Library" section and click on the "+" sign to create a playlist. When creating a playlist, users can add music tracks to the playlist.
After a playlist is created, users can add new tracks to this playlist, or remove tracks from this playlist. Users can also move tracks to new positions within a playlist. The following two images show the moving process:
At first, track 1 is "Perfect Duet", track 2 is "Always Remember Us This Way", track 3 is "Million Reasons", and track 4 is "I'll Never Love Again".
alt text
Next, we drag track 4 up to right above track 2.
After this dragging action, now, track 1 is still "Perfect Duet", track 2 is "I'll Never Love Again", track 3 is "Always Remember Us This Way", and track 4 is "Million Reasons".
alt text
Command Line Arguments
Your program will support 3 commands.
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.
./nyplaylists.exe playlist.txt library.txt output.txt add title
This command will add a music track (specified by the title) to the end of a playlist.
For example, the following command will add the song "Umbrella" to the end of the playlist.
./nyplaylists.exe playlist_tiny1.txt library.txt output.txt add "Umbrella"
Command 2: remove a music track from 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 "remove". The fifth argument is the title of the music track.
./nyplaylists.exe playlist.txt library.txt output.txt remove title
For example, the following command will remove the song "Always Remember Us This Way" from the playlist.
./nyplaylists.exe playlist_tiny1.txt library.txt output.txt remove "Always Remember Us This Way"
Command 3: move a music track to a new position on the 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 "move". The fifth argument is the title of the music track. The sixth argument is the new position - where this user wants the music track to be located on the playlist. 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.
./nyplaylists.exe playlist.txt library.txt output.txt move title [new_position]
For example, the following command will move the song "I Will Never Love Again - Film Version" to position 1.
./nyplaylists.exe playlist_tiny1.txt library.txt output.txt move "I Will Never Love Again - Film Version" 1
For all 3 commands, the output.txt contains the updated playlist. We have provided sample input & output files. Examples of using command line arguments can be found on the course webpage: Programming Information.
Input and Output File Format
All the input files and output files have the same format. Take the playlist_tiny1.txt as an example, this file has the following 4 lines:
"Perfect Duet" Ed Sheeran, Beyonce
"Always Remember Us This Way" Lady Gaga
"Million Reasons" Lady Gaga
"I Will Never Love Again - Film Version" Lady Gaga, Bradley Cooper
Each line has two fields, the music title, and the artist(s). There is one single space separating these two fields.
Handling Music Tracks with the Same Title
In cases where multiple tracks may have the same title, choose the first track from the input file. This is NOT the natural behavior of Spotify, but this decision is just to simplify your implementation.
Given a tiny playlist like:
"Perfect Duet" Ed Sheeran, Beyonce
"Always Remember Us This Way" Lady Gaga
"Million Reasons" Lady Gaga
"I Will Never Love Again - Film Version" Lady Gaga, Bradley Cooper
Our program should be able to add, remove, and move around songs into this playlist (For example)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 19th International Conference Dexa 2008 Turin Italy September 2008 Proceedings Lncs 5181

Authors: Sourav S. Bhowmick ,Josef Kung ,Roland Wagner

2008th Edition

3540856536, 978-3540856535

More Books

Students also viewed these Databases questions

Question

Explain the clinical features of specific phobias.

Answered: 1 week ago