Due: Monday 10/25 8:00 am
GitHub Submission Link: git@github.com:mks65/my_tunez.git
Music Library Overview
- You may work with a partner on this assignment. They must be in the same class period as you.
- Write a program in C that implements a music library organizer.
- This will consist of 2 data structures
- A linked list of songs.
- Your nodes/links should be able to hold a song’s title and artist. You might use structures like the following:
struct song_node{ char name[100]; char artist[100]; struct song_node *next; };
- Your nodes/links should be able to hold a song’s title and artist. You might use structures like the following:
- An array of 27 linked lists (one for each letter from ‘a’ to ‘z’, and another for other symbols).
- Each slot will contain a linked list of all the artists that have names that start with the corresponding letter.
- When you add a song, it should go on to a linked list at the appropriate array slot in the correct position alphabetically. Assume no duplicate songs.
- A linked list of songs.
Linked List Part
- You should start by making your linked lists work with the following functionality:
- insert nodes at the front
- insert nodes in order
- alphabetical by Artist then by Song
- you should have a helper function to compare song nodes effectively.
- print the entire list
- find and return a pointer to a node based on artist and song name
- find and return a pointer to the first song of an artist based on artist name
- Return a pointer to random element in the list.
- remove a single specified node from the list
- specified by both artist and song name.
- free the entire list
Library Part
DO NOT WORK ON THIS PART UNTIL YOUR LINKED LIST IS COMPLETE
- Then create your array of linked lists (suggested type:
struct song_node **
for the full program to have the following functions:- Allocate enough memory for 27 linked lists, make sure each entry is an empty list.
- Add song nodes.
- Search for a song given song and artist name (return a pointer).
- Search for an artist (return a pointer).
- Print out all the entries under a certain letter.
- Print out all the songs of a certain artist
- Print out the entire library.
- Shuffle - print out a series of randomly chosen songs.
- Delete a song
- Clear out all the linked lists in the library.
Putting it all together
- Files you should have:
- A .c file that contains the main function you use to test all your work
- You must test all the functions in your main function in order to receive full credit!!!
- A .c file that contains the main function you use to test all your work
- Two sets of .h/.c files
- There are 2 separate structures being worked on, the linked list and the library.
- A makefile that will compile all the parts of your code and generate a single executable program, as well as a run target.
Example testing
LINKED LIST TESTS
====================================
Testing print_list:
[ {ac/dc, thunderstruck} | {pearl jam, alive} | {pearl jam, even flow} | {pearl jam, yellow ledbetter} | {pink floyd, time} | {radiohead, paranoid android} | {radiohead, street spirit (fade out)} | ]
====================================
Testing print_node:
{ac/dc, thunderstruck}
====================================
Testing find_node:
looking for [pearl jam: even flow]
node found! {pearl jam, even flow}
looking for [pearl jam: daughter]
node not found
====================================
Testing find_artist:
looking for [pink floyd]
artist found! [ {pink floyd, time} | {radiohead, paranoid android} | {radiohead, street spirit (fade out)} | ]
looking for [pearl jam]
artist found! [ {pearl jam, alive} | {pearl jam, even flow} | {pearl jam, yellow ledbetter} | {pink floyd, time} | {radiohead, paranoid android} | {radiohead, street spirit (fade out)} | ]
looking for [presidents of the united states of america]
artist not found
====================================
Testing songcmp (helper function):
Comparing [pearl jam: even flow] to [pearl jam: even flow]
0
Comparing [pearl jam: even flow] to [pearl jam: alive]
4
Comparing [pearl jam: alive] to [pearl jam: even flow]
-4
Comparing [pearl jam: even flow] to [pink floyd: time]
-4
====================================
Testing random:
{pink floyd, time}
{radiohead, paranoid android}
{radiohead, street spirit (fade out)}
{pearl jam, alive}
====================================
Testing remove:
Removing [ac/dc: thunderstruck]
[ {pearl jam, alive} | {pearl jam, even flow} | {pearl jam, yellow ledbetter} | {pink floyd, time} | {radiohead, paranoid android} | {radiohead, street spirit (fade out)} | ]
Removing [radiohead: street spirit (fade out)]
[ {pearl jam, alive} | {pearl jam, even flow} | {pearl jam, yellow ledbetter} | {pink floyd, time} | {radiohead, paranoid android} | ]
Removing [pearl jam: yellow ledbetter]
[ {pearl jam, alive} | {pearl jam, even flow} | {pink floyd, time} | {radiohead, paranoid android} | ]
Removing [pearl jam: yellow ledbetter]
{pearl jam: yellow ledbetter} not found
[ {pearl jam, alive} | {pearl jam, even flow} | {pink floyd, time} | {radiohead, paranoid android} | ]
====================================
Testing free_list
freeing_node: {pearl jam, alive}
freeing_node: {pearl jam, even flow}
freeing_node: {pink floyd, time}
freeing_node: {radiohead, paranoid android}
list after free_list:
[ ]
====================================
MUSIC LIBRARY TESTS
====================================
Testing print_letter
[ ]
====================================
Testing print_library
====================================
Testing print_letter
[ {pearl jam, alive} | {pearl jam, even flow} | {pearl jam, yellow ledbetter} | {pink floyd, time} | {presidents of the united states of america, peaches} | ]
====================================
Testing print_library
a: [ {ac/dc, thunderstruck} | ]
p: [ {pearl jam, alive} | {pearl jam, even flow} | {pearl jam, yellow ledbetter} | {pink floyd, time} | {presidents of the united states of america, peaches} | ]
r: [ {radiohead, paranoid android} | {radiohead, street spirit (fade out)} | ]
====================================
Testing find:
looking for [pearl jam: alive]
song found! {pearl jam, alive}
looking for [pearl jam: time]
song not found
====================================
Testing find artist:
looking for [pearl jam]
artist found! [ {pearl jam, alive} | {pearl jam, even flow} | {pearl jam, yellow ledbetter} | {pink floyd, time} | {presidents of the united states of america, peaches} | ]
looking for [pink floyd]
artist found! [ {pink floyd, time} | {presidents of the united states of america, peaches} | ]
looking for [bob dylan]
artist not found
====================================
Testing remove_song
removing: [pearl jam: alive]
a: [ {ac/dc, thunderstruck} | ]
p: [ {pearl jam, even flow} | {pearl jam, yellow ledbetter} | {pink floyd, time} | {presidents of the united states of america, peaches} | ]
r: [ {radiohead, paranoid android} | {radiohead, street spirit (fade out)} | ]
removing: [pearl jam: yellow ledbetter]
a: [ {ac/dc, thunderstruck} | ]
p: [ {pearl jam, even flow} | {pink floyd, time} | {presidents of the united states of america, peaches} | ]
r: [ {radiohead, paranoid android} | {radiohead, street spirit (fade out)} | ]
====================================
Testing clear_library:
freeing_node: {ac/dc, thunderstruck}
freeing_node: {pearl jam, even flow}
freeing_node: {pink floyd, time}
freeing_node: {presidents of the united states of america, peaches}
freeing_node: {radiohead, paranoid android}
freeing_node: {radiohead, street spirit (fade out)}
Library after clear:
====================================
Adding songs to empty library
a: [ {ac/dc, thunderstruck} | ]
p: [ {pearl jam, alive} | {pearl jam, even flow} | {pearl jam, yellow ledbetter} | {pink floyd, time} | ]
====================================
Testing print_artist:
Printing [pearl jam]
pearl jam: {pearl jam, alive} {pearl jam, even flow} {pearl jam, yellow ledbetter}
Printing [ac/dc]
ac/dc: {ac/dc, thunderstruck}
====================================
Printing [radiohead]
radiohead:
====================================
Testing shuffle
{pink floyd, time}
{pearl jam, yellow ledbetter}
{pearl jam, alive}
====================================