1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
#include "song.h"
Song::Song()
{
init("no title","No artist","No Album", 0, 0);
}
Song::Song(const char name[])
{
init(title,"No artist","No album", 0, 0);
}
Song::Song(const char title[], float min)
{
init(title,"No artist", "No album", min, 0);
}
void Song::init(const char title[],const char artist[], const char album[], float min, float sec)
{
strcpy(this->title, title);
strcpy(this->artist, artist);
strcpy(this->album, album);
this->min = min;
this->sec=sec;
}
Song::~Song(){}
void Song::getTitle(char title[]) const
{
strcpy(title, this->title);
}
void Song::setTitle(const char title[])
{
strcpy(this->title, title);
}
void Song::getArtist(char artist[]) const
{
strcpy(artist, this->artist);
}
void Song::setArtist(const char artist[])
{
strcpy(this->artist, artist);
}
void Song::getAlbum(char album[]) const
{
strcpy(album, this->album);
}
void Song::setAlbum(const char album[])
{
strcpy(this->album, album);
}
void Song::setMin(float min)
{
this->min = min;
}
void Song::setSec(float sec)
{
this->sec=sec;
}
float Song::getSec() const
{
return sec;
}
void Song::readIn()
{
cout << "Please enter the song's Title: ";
getString(title, MAX_CHAR);
cout<< "Please enter the song's artist: ";
getString(artist, MAX_CHAR);
cout<<"Please enter the song's album: ";
getString(album, MAX_CHAR);
cout << "Please enter how many minutes are in the song: ";
min = getFloat();
cout<<"Please enter how many seconds remain in the song after the minutes you entered above are up: ";
sec=getFloat();
}
void Song::print() const
{
cout << title << ": " << artist<<":"<<album<< ":"<<min << ":"<<sec<<endl;
}
|