Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CD/DVD Collection This program will allow the user to keep track of a CD or DVD

ID: 3592307 • Letter: C

Question

CD/DVD Collection 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 different—your 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. For the CDs: Artist CD Name Length of CD Song Title Song Length Note: the artist name, CD name and length of CD should only appear once while the song title and length will have several lines. So the other columns must be displayed with blanks.

Explanation / Answer

void showList(string, double, int, string, string);
void showMenu();

class DVD
{
private:
string movie;   
double length;   
int year;   

public: // Constructors
   vector<string> actor; //To hold actors name
vector<string> charName; //To hold name of the character
void setMovie(string);
void setLength(double);
void setYear(int);
void addActor(string, string);
string getMovie() const;
double getLength() const;
int getYear()const;
string getActor() const;
  
   DVD()
   {
       movie = "";
       length = 0;
       year = 0;
   }
  
DVD(string m, double l, int y)
{
       movie = m;
length = l;
year = y;
   }
};

void DVD::setMovie(string m)
{movie = m;}

void DVD::setLength(double l)
{length = l;}

void DVD:: setYear(int y)
{year = y;}
  
void DVD::addActor(string actorName, string characterName)
{
   actor.push_back(actorName);
charName.push_back(characterName);
}
// Accessors
string DVD::getMovie() const
{ return movie; }
double DVD::getLength() const
{ return length; }
int DVD::getYear() const
{ return year; }
// I am having trouble here. How do I return both
// actor and charName in parallel??
//
string DVD::getActor(unsigned int index)
{
if(index >= name.size()) //Error name is undefined
return "no data";
return name[index];
}//Error: declaration incompatible with
//std::string DVD::getActor() const declared at line 34

int main()

{

int quantity; // To hold number actors/actresses
string name; // To hold actor/actress name
string charName; // To hold name of character
string title; // To hold movie title
double movieLength; // Local variable for length
int yearReleased; // Local variable for release date
  

fstream nameFile; // Fstream file object
int choice; // For menu choice

// Constants for menu choices
const int SHOW_LIST = 1,
ADD_DVD = 2,
REMOVE_DVD = 3,
UPDATE_DVD = 4,
QUIT_CHOICE = 5;

void DVD::addActor(string actorName, string characterName)
{
name.push_back(actorName); // push_back method adds next item to a vector
charName .push_back(characterName);
}
string DVD::getActor(unsigned int index)
{
if(index >= name.size())
return "no data";
return name[index];
}
void main(){
DVD mydvd;
mydvd.setMovie("The Godfather");
mydvd.addActor("Marlon B", "The mumbling guy");
mydvd.addActor("Al Pacino", "The crybaby");
cout << mydvd.getActor(0); // outputs "Marlon B" to the console
}

getline(cin, title);
cin >> movieLength;
cin >> yearReleased;

for (int index = 0; index < quantity; index++)
{
cout << "Enter actor #" << (index+1) << ": ";
getline(cin, name); //Is this right or should it be
// getline(cin, name[index]);
cin.ignore();
cout << "Enter the name of the character portrayed "
<< "by actor #" << (index+1) << ": ";
getline(cin, charName); //Same here?
cin.ignore();
}
cout << endl;
// Store the DVD details
mydvd.setMovie(title);
mydvd.setLength(movieLength);
mydvd.setYear(yearReleased);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote