Description
Implement the following functionalities of a music playlist using linked lists, stacks and queues.
● Store all songs in a linked list. The struct would contain the name of the song.
● Create a playlist from the library of songs created above, as a queue. To add a song to the playlist
● Search in the linked list. If it is there, print “Inserting into the play list” ● Enqueue the song. If not found, print “Sorry, song not found”.
● Play
○ Play Next: Dequeue and print “Playing <name of the song>”, then push into a “Recent songs” stack.
○ Play Previous (k):
■ For (i =1 to k)
● Pop a song from “Recent songs” stack, print “Playing <name of the song>”
● Enqueue into “Temporary Queue”
● If you run out of songs in the playlist, print “Sorry, there weren’t k recent songs”
■ Empty the Temporary Queue by dequeuing one by one and pushing into “Recent songs” stack.
Input (Messages from the program are shown here in bold for clarity; your program doesn’t need to print it in bold)
“Enter all songs (as strings), End with “-1″ ”
S1
S2
S3
S4
-1
“All songs entered!”
“Create Playlist, end with “-1″ ”
S5
“Not Found in the song library”
S1
“Found, Enqueued”
S3
“Found, Enqueued”
S4
“Found, Enqueued”
-1
“Playlist Ready!”
“Play next song, previous songs or end? n/p:k/e”
n Playing S1
“Play next song, previous songs or end? n/p:k/e”
n Playing S3
“Play next song, previous songs or end? n/p:k/e” p:3 Playing S3
Playing S1
“There aren’t 3 previous songs”
“Play next song, previous songs or end? n/p:k/e”
n Playing S4
“Play next song, previous songs or end? n/p:k/e” “Bye”
More examples in the image that follows in the next page.
Reviews
There are no reviews yet.