Académique Documents
Professionnel Documents
Culture Documents
Algorithm 4
The header file would include the creation of a class named playlist which will have the private
and public members. The public member of the class will constitute functions prototypes which
will basically be used to manipulate the playlist class. This will also contain the constructor and
destructor for the class.This will constitute of 4 basic functions, the first one would be a load
function which would load in the previously stored songs from the external data file into
dynamically allocated arrays using the new operator. This function returns the index number for
the number of elements in the array that have been filled this will help in the other functions. The
next function prototype would be a read function this function will ask users for input that they
want to add to the playlist. This data will then simultaneously be stored inside the dynamically
allocated arrays as well as read out to the external file. Into this function a counter integer
variable will be read in that will indicate the position from where to add data into the array as
well as the external file and this function will return the updated counter variable integer. Further
the next function prototype would be the search function to search and return the song the user
wants to see and finally the last function prototype would be the display all function which would
using a loop display all the contents of the playlist.
The private member of the class would include array declarations for storing the various facets
of the song playlist namely, artist name, song name, album name etc as well as the counter
integer variable.
A seperate .cpp file would be created to define all of the above state functions. This file will also
contain the constructor and destructor for the class. The main.cpp file would include the header
file and all the functions would be called from the main function along with functionality to
reiterate the process as many times as the user wants. In the main file we would first instantiate
a class object for the playlist, then the load function would be called to load the data into the
class as well as count the number of items. Then the read function would ask for user inputs
and append those to the end of file as well as add them to the arrays respectively. Next the
search function would be called for the user to be able to search the artist and display the
information about the artist and lastly the display function would be called so as to display the
entire contents of the playlist.