In: Computer Science
2) Complete the parameterized constructor that takes arguments that are used to initialize ALL class’s member variables. [2 points] 3) Complete the code for getTitle() member function. The function returns the title of the Song. [1 point] 4) Complete the code for getDurationSec() member function, which returns the duration in seconds instead of minutes. [2 points] 5) Write member function definitions for three member functions below: [3 points] void setTitle(string t); //set title to t void setAuthor(Author a); //set author to a void setDurationMin(double d); //set durationMin to d 6) Demonstrate how you can use the Song class in the main() function. Prompt users to enter the details of songs, store each song in a list (vector) then print out the Song objects from the list. The grading rubric for this question is shown below
CODE:
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class Song
{
public:
   Song(string title,string author,double min);
   ~Song();
   string getTitle();
   string getAuthor();
   double getDurationSec();
   void setTitle(string t);
   void setAuthor(string a);
   void setDurationMin(double d);
private:
   string m_title;
   string m_author;
   double m_duration;
};
Song::Song(string title, string author, double min)
{
   m_title = title;
   m_author = author;
   m_duration = min;
}
string Song::getTitle()
{
   return m_title;
}
string Song::getAuthor()
{
   return m_author;
}
double Song::getDurationSec()
{
   return m_duration * 60;
}
void Song::setTitle(string t)
{
   m_title = t;
}
void Song::setAuthor(string a)
{
   m_author = a;
}
void Song::setDurationMin(double d)
{
   m_duration = d;
}
Song::~Song()
{
}
int main()
{
   vector<Song> songs;
   int i = 0;
   while(i < 3)
   {
       string title, author;
       double dur;
       cout << "\nENter the Title of
the song";
       cin >> title;
       cout << "\nENter the author
of the song";
       cin >> author;
       cout << "\nENter the duration
of the song";
       cin >> dur;
       Song s(title, author, dur);
       songs.push_back(s);
       ++i;
   }
   for(Song s : songs)
   {
       cout << "\nTitle : " <<
s.getTitle();
       cout << "\nAuthor : "
<< s.getAuthor();
       cout << "\nTitle : " <<
s.getDurationSec();
   }
   return 0;
}