





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






#include
using namespace std;
class Track { char* trackName; int trackID; char lyrics; public: Track(){} // default constructor Track(char _tn, int tID, char* _lyrics) //parameterized constructor { setTrackName(_tn); setTrackID(tID); setLyrics(_lyrics); }//end parameterized constructor void setTrackName(char *tn) // setter function { if(tn != NULL) { trackName = new char[strlen(tn) + 1]; strcpy(trackName, tn); } else trackName = NULL; } void setTrackID(int n) // setter function { if(n > 0 && n < 99999) trackID = n; else trackID = -1; } void setLyrics(char *lyrcs) // setter function { if(lyrcs != NULL) { lyrics = new char[strlen(lyrcs) + 1]; strcpy(lyrics, lyrcs); } else lyrics = NULL; } Track(const Track & rhs) // copy constructor { if(rhs.trackName != NULL) { trackName = new char[strlen(rhs.trackName) + 1];
strcpy(trackName,rhs.trackName); } else trackName = NULL; trackID = rhs.trackID; if(rhs.lyrics != NULL) { lyrics = new char[strlen(rhs.lyrics) + 1]; strcpy(lyrics,rhs.lyrics); } else lyrics = NULL; }// end copy constructor ~Track() // destructor { if(trackName != NULL) delete[] trackName; if(lyrics != NULL) delete[] lyrics; }// end destructor void playTrack() { cout<<"playTrack() method is invoked."<<endl; } void stopTrack() { cout<<"stopTrack() method is invoked."<<endl; } void pauseTrack() { cout<<"pauseTrack() method is invoked."<<endl; } void downloadTrack() { cout<<"downloadTrack() method is invoked."<<endl; } char* getTrackName()const //getter function { return trackName; } int getTrackID()const //getter function { return trackID; } char* getLyrics() //getter function { return lyrics; } }; // end class Track
void setTrackNumber(int n) // setter function { t.setTrackID(n); } void setYear(int n) // setter function { if(n>0) year = n; else year = -1; } char* getTrack()const { t.getTrackName(); //used composition } void viewTrack() { cout<<"viewTrack() method is invoked."<<endl; } void viewTrackNumber() { cout<<t.getTrackID(); } void viewYear() { cout<<year<<endl; } int getAlbumID() { return albumID; } char* getTitle()const { return albumTitle; } }; // end class Album
class Artist { char* artistName; Album al; //composition Track tr; //composition public: Artist(){} // default constructor Artist(char* _artistName, char* _albums, char* _tracks)// parameterized constructor { setArtistName(_artistName); al.setAlbumTitle(_albums); tr.setTrackName(_tracks); } Artist(const Artist & rhs)// copy constructor {
if(rhs.artistName != NULL) { artistName = new char[strlen(rhs.artistName) + 1]; strcpy(artistName, rhs.artistName); } al.setAlbumTitle(rhs.al.getTitle()); tr.setTrackName(rhs.tr.getTrackName()); }// end copy constructor void setArtistName(char an) // setter function { if(an != NULL) { artistName = new char[strlen(an) + 1]; strcpy(artistName, an); } else artistName = NULL; } char getArtistName()const { return artistName; } ~Artist()//destructor { if(artistName != NULL) delete[] artistName; }//end destructor Album * getAlbum(int albumID) { return &al; } Track * getTrack(char * trackName) { return &tr; } }; // end class Artist
class Band { char* bandDetails; char* bandName; Artist ar;//composition public: Band() //Default Constructor {} Band(char *_bandDetails, char *_bandName, char *_artist)//parameterized Constructor { setBandDetails(_bandDetails); setBandName(_bandName); ar.setArtistName(_artist); }
if(rhs.bandDetails != NULL) { bandDetails = new char[strlen(rhs.bandDetails) + 1]; strcpy(bandDetails, rhs.bandDetails); } if(rhs.bandName != NULL) { bandName = new char[strlen(rhs.bandName) + 1]; strcpy(bandName, rhs.bandName); } ar.setArtistName(rhs.ar.getArtistName());
}// end copy constructor };//end class Band
class MusicCategory { protected: Artist* _artist; //Aggregation relationship Band* _band; //Aggregation relationship public: MusicCategory()//Default Constructor { _artist = NULL; _band = NULL; } MusicCategory(char* a, char* b) //parameterized constructor { _artist = new Artist(); _artist->setArtistName(a); _band = new Band("",b,a);
//_band->setBandName(b);
} MusicCategory(const MusicCategory & mc)//copy constructor of MusicCategory { _artist->setArtistName(mc._artist-
getArtistName()); _band->setBandName(mc._band- getBandName()); }//end copy constructor of MusicCategory ~MusicCategory()//destructor {
delete _artist; delete _band; } Artist * getArtist(char * artistName)const { return _band->getArtist(artistName); } Album * getAlbum(int albumID)const { return _artist->getAlbum(albumID); } Track * getTrack(char * trackID)const { return _artist->getTrack(trackID); } Band * getBand(char * bandName)const { return _band->getBand(bandName); }
};//end class MusicCategory
class MusicItems { MusicCategory mc;// Composition relationship public: MusicItems(const MusicCategory & gmc) //Class Constructor { cout<<"\n*****************************************\n"; cout<<"get all Music Items from DB into mc"; cout<<"\n*****************************************\n";
mc = gmc; } Album * getAlbum(int albumID) { Album * tempAlbum = mc.getAlbum(albumID); return tempAlbum; } Artist * getArtist(char * artistName) { Artist * tempArtist = mc.getArtist(artistName); return tempArtist; } Track * getTrack(char * trackID) { Track * tempTrack = mc.getTrack(trackID); return tempTrack; } Band * getBand(char * bandName) { Band * tempBand = mc.getBand(bandName); return tempBand; }