Suggest ideas for dealing with list data that has permanace and be stored and re
ID: 3596715 • Letter: S
Question
Suggest ideas for dealing with list data that has permanace and be stored and retrieved as needed. Use code fragments to illustrate your response. Suggest ideas for dealing with list data that has permanace and be stored and retrieved as needed. Use code fragments to illustrate your response. Suggest ideas for dealing with list data that has permanace and be stored and retrieved as needed. Use code fragments to illustrate your response. Suggest ideas for dealing with list data that has permanace and be stored and retrieved as needed. Use code fragments to illustrate your response. Suggest ideas for dealing with list data that has permanace and be stored and retrieved as needed. Use code fragments to illustrate your response.Explanation / Answer
#include "stdafx.h"
#define kMaxLineSize 2048
#define kMusicLibraryFileName "music.txt"
using namespace std;
struct song { string artist; string title; int duration; };
class Playlist { public: string clear()
{
playList.erase(playList.begin(), playList.end());
return "Cleared play list";
};
string load(string fileName)
{
ifstream musicFile(fileName.c_str());
if(!musicFile) { cout exit(1);
}
while(!musicFile.eof())
{
// Read a line from file
string bufString;
getline(musicFile, bufString);
vector tokens = tokenizer(bufString, ","); /// Adding song to library
if(tokens.size() == 3)
{
song newSong;
newSong.artist = tokens.at(0);
newSong.title = tokens.at(1);
newSong.duration = atoi(tokens.at(2).c_str());
playList.push_back(newSong);
}
}
return "Loaded music data";
}
string info()
{ ostringstream ost;
vector ::iterator i;
for(i = playList.begin();
i != playList.end(); i++) { ost }
return ost.str();
}
string add()
{
// Roll you own song adding routine...
song newSong;
newSong.artist = "The Adders";
newSong.title = "Adding at the end";
newSong.duration = 120;
playList.push_back(newSong); return "Added song"; };
string save(string fileName)
{
ofstream musicFile(fileName.c_str());
if(!musicFile) { cout exit(1);
}
musicFile musicFile
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.