CS120
Lab #12
For this lab you will be creating a "song" class to store songs and
use it to create a program to allow users to search for songs by name.
You may do this lab as a pair programming assignment.
The song class should have the following data members and methods:
- Data member: A string for the song name.
- Data member: A string for the aritist's name.
- Data member: A double for the song length (e.g. 3.5 would be a 3 minute, 30 second song).
- Data member: One other data member of your choice. Possiblities include
the year, the album title, the genre, etc.
- Method: default constructor, which should give appropriate values
to all of the data members.
- Method: explicit constructor, which should have one parameter
for each of the class data members and set the data members appropriately.
- Method: print, which prints all of the information about a song.
- Method: set_data, which, like the explicit constructor, has one parameter
for each data member and set the data members appropriately.
- Method: check_name, which takes a string as an argument and compares it
to the song's name, returning a 1 if the names match and a 0 otherwise.
To test the class write a main program that does the following:
- Creates an array of 5 song objects.
- Set the data for all 5 song objects. You can hard code this, let the user enter
the data for the 5 songs, or load the 5 songs from a file.
- Prints all of the songs in the array using the class's print function.
- Has the user enter a song name, then searches through the array of songs
using the check_name method to find the named song and prints it, or, if it
is not in the array, prints a message saying the song is not in the "database".
Turn in: the class, the main program, and sample output showing that
the code works, including finding a song by name, and failing to find
a song.