Question: I can't get my code to work properly. It runs lines together when compiled. I need the information to match the following question exactly. Please

I can't get my code to work properly. It runs lines together when compiled. I need the information to match the following question exactly. Please help.

This program will allow the user to keep track of a CD or DVD collection. This can only work exclusively with either CDs or DVDs since some of the data is differentyour choice. Each CD/DVD in the collection will be represented as a class, so you will have one class that is a single CD/DVD. The CD class will use a vector to keep track of the titles of the songs on the CD; this will allow each CD to have a different number of songs. It should also maintain the length of each song thus another vector. The class will also keep track of the total length of the CD. The class will also have a data member for the artist name and the name of the CD. The DVD class will have data members for the title of the movie, the length of the movie, and the year the movie was released. The class will have a vector which is used to store the name of the actors and actresses in the movie. Another vector will be used to maintain the character names that the actor/actress played in the movie. These two vectors must work in parallel, meaning the first actor/actress in the list must correspond to the first character in the other vector. The program will maintain a list of CD/DVDs. This list will be a vector of that class type (CD or DVD). The program must provide methods (functions) to add a CD/DVD, remove a CD/DVD and update a CD/DVD. There should also be a function that displays the entire list of CDs/DVDs. The output must be a table format, with heading. For the DVDs: Movie Title Length of Movie Year Released Actors/Actresses Characters Note: the movie title, length of movie and year released should only appear once while the actors/actresses and characters will have several lines. So the other columns must be displayed with blanks.

source.cpp

#include "Media.h"

#include "DVD.h"

#include

#include

void addDVD(list dvds);

void removeDVD(list dvds);

void updateDVD(list dvds);

void showDVDs(list dvds);

int main()

{

list dvds;

int choice;

do

{

cout << "-----MENU-----" << endl;

cout << "1. Add DVD" << endl;

cout << "2. Remove DVD" << endl;

cout << "3. Update DVD" << endl;

cout << "4. Show DVDs" << endl;

cout << "5. Exit" << endl;

cout << "Enter your choice: ";

cin >> choice;

switch (choice)

{

case 1:

addDVD(dvds);

break;

case 2:

removeDVD(dvds);

break;

case 3:

updateDVD(dvds);

break;

case 4:

showDVDs(dvds);

break;

case 5:

cout << "Thank you." << endl;

break;

default:

cout << "Invalid Choice!" << endl;

}

cout << endl;

} while (choice != 9);

system("pause");

return 0;

}

void addDVD(list dvds)

{

string str, name, str1, str2;

int len, yr, n;

cout << " Enter DVD name: ";

getline(cin, name);

cout << "Enter DVD length: ";

getline(cin, str);

len = atoi(str.c_str());

cout << "Enter DVD year: ";

getline(cin, str);

yr = atoi(str.c_str());

DVD dvd(name, len, yr);

cout << "Enter number of actors: ";

getline(cin, str);

n = atoi(str.c_str());

for (int i = 0; i < n; i++)

{

cout << "Enter name of actor #" << (i + 1) << ": ";

getline(cin, str1);

cout << "Enter character of actor #" << (i + 1) << ": ";

getline(cin, str2);

dvd.addActor(str1, str2);

}

dvds.push_back(dvd);

}

void removeDVD(list dvds)

{

string name;

cout << " Enter DVD name: ";

getline(cin, name);

list::iterator itr;

for (itr = dvds.begin(); itr != dvds.end(); itr++)

{

if (strcmp(itr->getName().c_str(), name.c_str()) == 0)

{

dvds.erase(itr);

break;

}

}

}

void updateDVD(list dvds)

{

string name, str1, str2;

cout << " Enter DVD name: ";

getline(cin, name);

list::iterator itr;

for (itr = dvds.begin(); itr != dvds.end(); itr++)

{

if (strcmp(itr->getName().c_str(), name.c_str()) == 0)

{

cout << "Enter name of actor: ";

getline(cin, str1);

cout << "Enter character of actor: ";

getline(cin, str2);

itr->updateActor(str1, str2);

break;

}

}

}

void showDVDs(list dvds)

{

list::iterator itr;

for (itr = dvds.begin(); itr != dvds.end(); itr++)

{

cout << "DVD name: " << itr->getName() << endl;

cout << "DVD length: " << itr->getLength() << endl;

cout << "DVD year: " << itr->getYear() << endl;

itr->showActors();

cout << endl;

}

}

media.cpp

#include "Media.h"

Media::Media(string str, double len)

{

name = str;

length = len;

}

string Media::getName()

{

return name;

}

int Media::getLength()

{

return length;

}

media.h

#ifndef MEDIA_H

#define MEDIA_H

#include

#include

using namespace std;

class Media

{

public:

Media(string str, double len);

string getName();

int getLength();

private:

string name;

int length;

};

#endif

dvd.cpp

#include "DVD.h"

DVD::DVD(string str, double len, int yr) : Media(str, len)

{

year = yr;

}

int DVD::getYear()

{

return year;

}

void DVD::addActor(string str1, string str2)

{

Actor c;

c.actorName = str1;

c.characterName = str2;

actors.push_back(c);

}

void DVD::removeActor(string str1, string str2)

{

Actor c;

c.actorName = str1;

c.characterName = str2;

list::iterator itr;

for (itr = actors.begin(); itr != actors.end(); itr++)

{

if (strcmp(itr->actorName.c_str(), str1.c_str()) == 0)

{

actors.erase(itr);

break;

}

}

}

void DVD::updateActor(string str1, string newCharacter)

{

list::iterator itr;

for (itr = actors.begin(); itr != actors.end(); itr++)

{

if (strcmp(itr->actorName.c_str(), str1.c_str()) == 0)

{

actors.erase(itr);

Actor c;

c.actorName = str1;

c.characterName = newCharacter;

actors.push_back(c);

break;

}

}

}

void DVD::showActors()

{

list::iterator itr;

for (itr = actors.begin(); itr != actors.end(); itr++)

cout << itr->actorName << " " << itr->characterName << endl;

}

dvd.h

#ifndef DVD_H

#define DVD_H

#include "Media.h"

#include

#include

struct Actor

{

string actorName;

string characterName;

};

class DVD : public Media

{

public:

DVD(string str1, double len, int yr);

int getYear();

void addActor(string str1, string str2);

void removeActor(string str1, string str2);

void updateActor(string str1, string newCharacter);

void showActors();

private:

list actors;

int year;

};

#endif

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!