Many of us have large digital music collections that are not always very well or
ID: 3562080 • Letter: M
Question
Many of us have large digital music collections that are not always very well organized. It would be nice to have a program that would arrange our music collection based attributes such as artist, album title, song title, genre, song length, number times played, and rating. For this assignment you will write a digital music manager (DMM).
Your DMM program must have a text-based interface which allows the user to select from a menu of options including: load, store, display, insert, delete, edit, sort, rate, and exit. The
Explanation / Answer
song.h file
#include <iostream>
#include <string>
using namespace std;
class Song
{
public:
Song(); //default constructor
Song(string aTitle, string anArtist, string anAlbum ,string aGenre, int aSong_len, int aNum_Player , int aRating ); //parametrized constructor
string getTitle()const; // return value title
string getArtist()const; // return value artist
string getAlbum()const; // return value album title
string getGenre()const; //return Genre value
int getSong_len()const; //return song lenth
int getNum_Player()const; //return number of time play value
int getRating() const; //return rating of song
void setTitle(string newTitle);
void setArtist(string newArtist);
void setAlbum(string newAlbum);
void setGenre(string newGenre);
void setSong_len(int newSong_len);
void setNum_Player(int newNum_Player);
void setRating(int newRating);
string toDisplayString() const;
string toSaveString() const;
void Addsong(int counter);
void Remove(int counter);
void Display();
void Exit();
private:
string ttl; //title
string art; //artist
string alb; // album
String gen; //genre
Int slen; //lenth
Int pla; //play
Int rat; //rate
};
song.cpp file
#include <iostream>
#include <string>
#include "Song.h"
using namespace std;
Song:: Song()
{
ttl= " ";
art = " ";
alb = " ";
gen = " ";
slen = null;
pla = null;
rat = null;
}
Song::Song(string aTitle, string anArtist, string anAlbum, string aGenre, int aSong_len, int aNum_Player , int aRating )
{
ttl = aTitle; //Assing parameters
art = anArtist;
alb = anAlbum;
gen = aGenre;
slen = aSong_len;
pla = aNum_Player;
rat = aRating;
}
string Song::getTitle() const
{
return ttl;
}
void Song:: setTitle(string newTitle)
{
ttl= newTitle;
}
string Song::getArtist() const
{
return art;
}
void Song:: setArtist(string newArtist)
{
art=newArtist;
}
string Song::getAlbum() const
{
return alb;
}
void Song::setAlbum(string newAlbum)
{
alb= newAlbum;
}
string Song::toDisplayString() const
{
string result = " Title: " + ttl;
result += " Author: " + art;
result += " Album: " + alb + " ";
return result;
}
string Song:: toSaveString() const
{
return ttl+ " : " + art + " : " + alb;
}
string Song::getGenre() const
{
return gen;
}
void Song:: setGenre(string newGenre)
{
gen=newGenre;
}
int Song::getSong_len() const
{
return slen;
}
void Song:: setSong_len(int newSong_len)
{
slen=newSong_len;
}
int Song::getNum_Player() const
{
return pla;
}
void Song:: setNum_Player(int newNum_Player)
{
pla=newNum_Player;
}
int Song::getRating() const
{
return rat;
}
void Song:: setRating(int newRating)
{
rat=newRating;
}
songList.cpp file:
#include <iostream>
#include <fstream>
#include <string>
#include "Song.h"
using namespace std;
int option;
int menu
int counter = 0;
Song collection[200];
int menu()
{
//Displaying the menu //
cout << "What do you want to do" << endl;
cout << "1. Add a song" << endl;
cout << "2. Remove a song" << endl;
cout << "3. Display all the songs in the list" << endl;
cout << "4. Quit" << endl;
/// Getting input
cin >> option;
//Selecting case and calling functions associated
switch (option) {
case 1:
cout << " Add a song" << endl;
void AddSong (int counter);
counter++;
break;
case 2:
cout << " Remove a song" << endl;
void Remove();
break;
case 3:
cout << " Display a song" << endl;
void Display();
break;
case 4:
cout<< " Quit" << endl;
void Exit();
break;
default:
cout << " Input a value between 1-4" << endl;
return menu();
}
void Addsong(int counter)
{
cout << " Enter song title:" << endl;
getline(cin, ttl);
collection[counter].setTitle(ttl);
cout << " Enter song artist:" << endl;
getline(cin, art);
collection[counter].setArtist(art);
cout << " Enter song album:" << endl;
getline(cin, alb);
collection[counter].setAlbum(alb);
return menu();
}
void Remove(int counter);
{
cout << " Enter song title:" << endl;
getline(cin, ttl);
collection[counter].setTitle(ttl);
cout << " Enter song artist:" << endl;
getline(cin, art);
collection[counter].setArtist(art);
cout << " Enter song album:" << endl;
getline(cin, alb);
collection[counter].setAlbum(alb);
cout << " Enter song generic:" << endl;
getline(cin, gen);
collection[counter].setAlbum(gen);
cout << " Enter song length:" << endl;
getline(cin, slen);
collection[counter].setAlbum(slen);
cout << " Enter number of time song play:" << endl;
getline(cin, pla);
collection[counter].setAlbum(pla);
cout << " Enter song rating:" << endl;
getline(cin, rat);
collection[counter].setAlbum(rat);
return menu();
}
void Display(int counter);
{
int loco;
Song list;
cout << " Here are the songs in your collection: " << endl;
for(loco = 0; loco < 10; loco++);
{
list = collection[loco];
if(loco + 1 < 10)
{
cout << " " << loco + 1 << " | ";
}
else
cout << loco + 1 << " | ";
}
cout << " Here are the songs in your collection:" << endl;
cout << "Title:" << list.getTitle() << endl;
cout << "Artist:" << list.getArtist()<< endl;
cout << "Generic:" << list.getGenre()<< endl;
cout << "Song length:" << list.getSong_len()<< endl;
cout << "Play:" << list.getNum_Player()<< endl;
cout << "Rating:" << list.getRating()<< endl;
cout << "Album:" << cout << list.getAlbum() << endl;
return menu();
}
void Exit()
{
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.