This program will allow the user to keep track of a CD or DVD collection. This c
ID: 3539666 • Letter: T
Question
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%u2014your 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
DVD CLASS
#include "DVD.h"
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class DVD //Redefinition of 'DVD'
{
private:
string title; //Holds title of dvd
int year; //Year made
double length; //Holds length of movie
public:
vector<string> actrs; //Actors and Actresses
vector<string> charNames; //Character names
void setTitle(string);
void setLength(double);
void setYear(int);
void addActChar(string, string);
string getTitle();
double getLength();
int getYear();
DVD() //Expected member name or ';' after declaration specifiers
{
title = "";
year = 0;
length = 0;
}
};
MY HEADER FILE FOR DVD CLASS
#ifndef __DVD_Database__DVD__
#define __DVD_Database__DVD__
#include <iostream>
#include "DVD.cpp"
#include <vector>
#include <string>
DVD DVD;
void DVD::setTitle(string t)
{
title = t;
}
void DVD::setLength(double l)
{
length = l;
}
void DVD::setYear(int y)
{
year = y;
}
void DVD::addActChar(string actrs, string charNames)
{
actor.push_back(actrs); //Undeclared identifier 'actor'
charat.push_back(charNames); //Undeclared identifier 'charat'
//pushback character
}
#endif /* defined(__DVD_Database__DVD__) */
MAIN
#include "DVD.h"
#include "DVD.cpp"
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
int selection; //Used for menu system
int numPeep; //Holds the number of people in the movie
string title; //Holds title of dvd
int year; //Year made
double length; //Holds length of movie
string actor; //Hold actor/actress name/
string charat; //Holds character name
class DVD DVD; //DVD Object
//Menu System
cout << "*****************************************************************************************" << endl;
cout << "* *" << endl;
cout << "* DVD Collection *" << endl;
cout << "* *" << endl;
cout << "*****************************************************************************************" << endl;
cout << endl;
cout << endl;
cout << "1. Add DVD" << endl;
cout << "2. Remove DVD" << endl;
cout << "3. Update DVD" << endl;
cout << "4. Show DVDs" << endl;
cin >> selection;
switch (selection)
{
case 1:
{
cout << "To add a new DVD please enter the title, length, year release, actors and their charactors" << endl;
cout << endl;
cout << "Movie Title: ";
getline(cin, title);
cout << endl;
cout << "Length: ";
cin >> length;
cout << endl;
cout << "Year: ";
cin >> year;
cout << endl;
cout << "You entered: " << title << " " << length << " " << year << endl;
cout << endl;
cout << "How many actors/characters do you want to add?" << endl;
cout << "#: ";
cin >> numPeep;
//Loop to pull in actors/ actresses
for (int i = 0; i < numPeep; i++)
{
//Actor and Actress
cout << "Actor/Actress " << (i + 1) << "Name: ";
getline(cin, actor);
cout << endl;
//Character they play
cout << "Character they play: ";
getline(cin, charat);
}
//Store dvd information
DVD.setTitle(title);
DVD.setYear(year);
DVD.setLength(length);
DVD.addActChar(actor, charat);
}break;
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.