The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 2 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
c++
.h and cpp file
Â
quick question, is this question asking to do two program ? one for DVD,one for CD? I am confused....
Â
Â
Â
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.
*/#ifndef DVD_H
#define DVD_H
#include <iostream>
#include <string>
#include <vector>
using namespace std;
class 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 t) {
      this->title = t;
   }
   ;
   void setLength(double length) {
      this->length = length;
   }
   ;
   void setYear(int year) {
      this->year = year;
   }
   ;
   void addActChar(string actor, string names) {
      this->actrs.push_back(actor);
      this->charNames.push_back(names);
   }
   ;
   string getTitle() {
      return this->title;
   }
   ;
   double getLength() {
      return this->length;
   }
   ;
   int getYear() {
      return this->year;
   }
   ;
   DVD() {
      title = "";
      year = 0;
      length = 0;
   }
};
#endif
#include "DVD.h"
#include <iostream>
#include <string>
#include <vector>
#include<cstring>
using namespace std;
int main()
{
   int choice;
   int numPeep;
   string title;
   int year;
   double length;
   string actor;
   string charat;
   DVD dvd;
   vector<DVD> testDVD;
   vector<string> actrs;    //Actors and Actresses
   vector<string> charNames; //Character names
   //Menu System
   while (true) {
      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:
         cin.ignore();
         cout << "Movie Title: ";
         getline(cin, title);
         cout << "Length: ";
         cin >> length;
         cout << "Year: ";
         cin >> year;
         cout << "You entered: " << title << " " << length << " " << year
               << endl;
         cout << endl;
         cout << "How many actors/characters do you want to add? ";
         cin >> numPeep;
         cin.ignore();
         for (int i = 0; i < numPeep; i++) {
            //Actor and Actress
            cout << "Actor/Actress " << (i + 1) << " Name: ";
            getline(cin, actor);
            //Character they play
            cout << "Character they play: ";
            getline(cin, charat);
            dvd.addActChar(actor, charat);
         }
         dvd.setTitle(title);
         dvd.setYear(year);
         dvd.setLength(length);
     Â
         testDVD.push_back(dvd);
         break;
      case 2:
         cin.ignore();
         cout << "Enter Movie Title to remove: ";
         getline(cin, title);
         for (int i = 0; i < testDVD.size(); i++) {
            dvd = testDVD[i];
            if (strcmp(testDVD[i].getTitle().c_str(), title.c_str()) == 0) {
               testDVD.erase(testDVD.begin() + i);
            }
         }
         break;
      case 3:
         cin.ignore();
         cout << "Enter Movie Title to update: ";
         getline(cin, title);
         cout << "Length: ";
         cin >> length;
         cout << "Year: ";
         cin >> year;
         cout << "You entered: " << title << " " << length << " " << year
               << endl;
         cout << endl;
         cout << "How many actors/characters do you want to add? ";
         cin >> numPeep;
         cin.ignore();
         for (int i = 0; i < numPeep; i++) {
            //Actor and Actress
            cout << "Actor/Actress " << (i + 1) << " Name: ";
            getline(cin, actor);
            //Character they play
            cout << "Character they play: ";
            getline(cin, charat);
         }
         dvd.setTitle(title);
         dvd.setYear(year);
         dvd.setLength(length);
         dvd.addActChar(actor, charat);
         for (int i = 0; i < testDVD.size(); i++) {
            dvd = testDVD[i];
            if (strcmp(testDVD[i].getTitle().c_str(), title.c_str()) == 0) {
               testDVD[i] = (dvd);
            }
         }
         break;
      case 4:
         for (int i = 0; i < testDVD.size(); i++) {
            dvd = testDVD[i];
            cout << "DVD Title : " << dvd.getTitle() << endl;
            cout << "Year Released : " << dvd.getYear() << endl;
            cout << "Length of Movie: " << dvd.getLength() << endl;
            cout << "Actors/Actresses: " << endl;
            for (int i = 0; i < dvd.actrs.size(); i++) {
               cout << dvd.actrs[i] <<endl;
            }
            cout << endl;
            cout << "Characters: " << endl;
            for (int i = 0; i < dvd.charNames.size(); i++) {
               cout << dvd.charNames[i] << endl;
            }
            cout << endl;
         }
         break;
      case 5:
         cout << "Thank you!" << endl;
         return 0;
         break;
      }
   }
}
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly