Question
I can't get my code to work properly. It will not display the DVD collection after items have been input. I need the information to
I can't get my code to work properly. It will not display the DVD collection after items have been input. 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.
#include "Media.h"
#include "DVD.h"
#include
#include
void addDVD(list
void removeDVD(list
void updateDVD(list
void showDVDs(list
int main()
{
list
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 != 5);
system("pause");
return 0;
}
void addDVD(list
{
string str, name, str1, str2;
int len, yr, n;
cin.clear();
cin.ignore();
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
{
string name;
cin.clear();
cin.ignore();
cout << " Enter DVD name: ";
getline(cin, name);
list
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
{
string name, str1, str2;
cin.clear();
cin.ignore();
cout << " Enter DVD name: ";
getline(cin, name);
list
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
{
list
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;
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started