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

Need help breaking this program into header and class files: looking for Dvd.h,

ID: 3564230 • Letter: N

Question

Need help breaking this program into header and class files: looking for Dvd.h, Dvd.cpp, and main.cpp

#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <iomanip>
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>

using namespace std;
void showList (string,double, int, string, string);
void showMenu();



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

public:
    vector<string> actor;
    vector<string> charName;

    void setMovie(string);
    void setlength(double);
    void setYear(int);
    void addActor(string,string);

    string getMovie()const;
    double getlength()const;
    int getYear()const;
    string getActor(unsigned int index)const;
void display_DVD();


    DVD()
    {
        movie = "";
        length = 0;
        year = 0;
    }

    DVD(string m, double l, int y)
    {
        movie = m;
        length = l;
        year = y;
    }


};//end of class


//mutators
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;
}
string DVD::getActor(unsigned int index)const
{
if (index >= actor.size())
        return "no data";
     return actor[index];
}

void DVD::display_DVD()
{

cout<<setw(15)<<"Movie Title"<<setw(15)<<" Length of Movie "<<setw(10)<<"Year Released "<<setw(15)<<"Actors/Actresses"<<setw(15)<<"Characters"<<endl;
cout<<setw(15)<<movie<<setw(15)<<length<<setw(10)<<year<<setw(20)<<actor[0]<<setw(20)<<charName[0]<<endl;


for(int i=1;i<actor.size();i++)
{
cout<<setw(60)<<actor[i]<<setw(20)<<charName[i]<<endl;

}
}




vector<DVD> DVD_Collection;
DVD add_a_dvd()
{

DVD mydvd;


    int quantity;       //to hold number
    string name;        //to hold actor name
    string chName;      //to hold name of character
    string title;       //to hold movie title
    double movieLength; //to hold movie time length
    int yearReleased;   // to hold release date


         cout <<"Enter the movie title, length, and year released. "
         << "Hit [enter] after each input"<<endl;
         getline(cin,title,' ');
         cin >> movieLength;
         cin >> yearReleased;

         cout << "How many actor names would you like to add to this movie description? ";
         cin >> quantity;
cin.ignore();

         mydvd.setMovie(title);
         mydvd.setlength(movieLength);
         mydvd.setYear(yearReleased);

         for (int index = 0; index < quantity; index++)
         {
             cout << "Enter actor #"<< (index + 1) << ": ";
             getline(cin, name,' ');
            // cin.ignore();
             cout << "Enter the name of the character protrayed " << "by actor #" << (index +1) << ": ";
             getline(cin, chName,' ');

             cout << endl;
             mydvd.addActor(name,chName);

         }

cout<<endl<<endl;

return mydvd;

}

void Modify()
{
string moviename;
bool check=false;

cout<<" Enter The Name Of The Movie You Want To Modify. "<<endl;
getline(cin,moviename,' ');
for(int i=0;i<DVD_Collection.size();i++)
   {
if(DVD_Collection[i].getMovie()==moviename)
{
            check=true;
            int quantity;       //to hold number
string name;        //to hold actor name
   string chName;      //to hold name of character
string title;       //to hold movie title
double movieLength; //to hold movie time length
int yearReleased;   // to hold release date

cout<<"     -----Previous Data Of This DVD-----   "<<endl;

DVD_Collection[i].display_DVD();



cout<<" Please Re Input This DVD "<<endl;
         cout <<"Enter the movie title, length, and year released. "
         << "Hit [enter] after each input"<<endl;
         getline(cin,title,' ');
         cin >> movieLength;
         cin >> yearReleased;

         cout << "How many actor names would you like to add to this movie description? ";
         cin >> quantity;
cin.ignore();

         DVD_Collection[i].setMovie(title);
         DVD_Collection[i].setlength(movieLength);
         DVD_Collection[i].setYear(yearReleased);
DVD_Collection[i].actor.clear();
DVD_Collection[i].charName.clear();

         for (int index = 0; index < quantity; index++)
         {
             cout << "Enter actor #"<< (index + 1) << ": ";
             getline(cin, name,' ');
            // cin.ignore();
             cout << "Enter the name of the character protrayed " << "by actor #" << (index +1) << ": ";
             getline(cin, chName,' ');

             cout << endl;
             DVD_Collection[i].addActor(name,chName);

         }

cout<<endl<<endl;
}
}
if(check==false)
cout<<" DVD With This Movie Not Found.."<<endl<<endl;

}

bool REMOVE_DVD()
{
string moviename;

cout<<" Enter The Name Of The Movie You Want To Delete. "<<endl;
getline(cin,moviename,' ');


if(DVD_Collection.empty())
{

cout<<" You have No DVD in your collections "<<endl;
return false;

}

for(int i=0;i<DVD_Collection.size();i++)
{
if(DVD_Collection[i].getMovie()==moviename)
{
DVD_Collection.erase(DVD_Collection.begin()+i);
cout<<" Movie: "<<moviename<<" is no more in Movie Collection! "<<endl;
return true;
}
}

cout<<" Movie with name "<<moviename<<" was not found in the Movie Collection! "<<endl;

return true;
}

void Display_DVD_organizer()
{
system("CLS");
if(DVD_Collection.empty())
{
cout<<" DVD Organizer Is Empty "<<endl;
return;
}
int count=0;

cout<<"                     DVD LIST "<<endl<<endl;

for(int i=0;i<DVD_Collection.size();i++)
{
DVD_Collection[i].display_DVD();

cout<<endl<<"----------------------------------------------------------------------"<<endl;
count++;
}
cout<<endl<<endl<<" TOTAL DVD's ="<<count<<endl<<endl;

}



void menu()
{


   string userOption;
   string userInput;
   bool exitProgram = false;

   while (!exitProgram)
   {
     system("CLS") ;// clears the screen !!
      cout << endl << "                    ";
cout<<"DVD ORGANIZER MAIN MENU" << endl << endl;

      cout << "   1. Add New DVD." << endl;
      cout << "   2. Modify A DVD By Movie Name." << endl;
cout << "   3. Delete A DVD By Movie Name. "<<endl;
      cout << "   4. Display DVD Organizer." << endl;
      cout << endl << " 99. Exit program." << endl << endl;

      cout << "Option> ";
      getline(cin, userOption, ' ');


      switch (atoi(userOption.c_str()))
      {
          case 1:
DVD_Collection.push_back(add_a_dvd());
            break;

          case 2:
system("CLS");
Modify();
   system("Pause");
break;

            case 3:

REMOVE_DVD();

system("Pause");
            break;

case 4:

Display_DVD_organizer();
system("Pause");
break;

            case 99:
             exitProgram = true;
            break;

          default:

            cerr << "Error: unknown option!" << endl;

system("Pause");
            break;
      }
   }

   return;
}




int main()
{
    menu();

    return 0;
}

Explanation / Answer

DVD.CPP

#include "dvd.hpp"
#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <iomanip>
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
using namespace std;
void showList (string,double, int, string, string);
void showMenu();

//mutators

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;
}
string DVD::getActor(unsigned int index)const
{
if (index >= actor.size())
        return "no data";
     return actor[index];
}

void DVD::display_DVD()
{

cout<<setw(15)<<"Movie Title"<<setw(15)<<" Length of Movie "<<setw(10)<<"Year Released "<<setw(15)<<"Actors/Actresses"<<setw(15)<<"Characters"<<endl;
cout<<setw(15)<<movie<<setw(15)<<length<<setw(10)<<year<<setw(20)<<actor[0]<<setw(20)<<charName[0]<<endl;


for(int i=1;i<actor.size();i++)
{
cout<<setw(60)<<actor[i]<<setw(20)<<charName[i]<<endl;

}
}


int main()
{
    menu();
    return 0;
}


DVD.HPP

#include <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <iomanip>
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
using namespace std;
void showList (string,double, int, string, string);
void showMenu();


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

public:
    vector<string> actor;
    vector<string> charName;
    void setMovie(string);
    void setlength(double);
    void setYear(int);
    void addActor(string,string);
    string getMovie()const;
    double getlength()const;
    int getYear()const;
    string getActor(unsigned int index)const;
    void display_DVD();
    void menu();
    DVD()
    {
        movie = "";
        length = 0;
        year = 0;
    }

    DVD(string m, double l, int y)
    {
        movie = m;
        length = l;
        year = y;
    }
};//end of class


vector<DVD> DVD_Collection;
DVD add_a_dvd()
{

DVD mydvd;


    int quantity;       //to hold number
    string name;        //to hold actor name
    string chName;      //to hold name of character
    string title;       //to hold movie title
    double movieLength; //to hold movie time length
    int yearReleased;   // to hold release date


         cout <<"Enter the movie title, length, and year released. "
         << "Hit [enter] after each input"<<endl;
         getline(cin,title,' ');
         cin >> movieLength;
         cin >> yearReleased;

         cout << "How many actor names would you like to add to this movie description? ";
         cin >> quantity;
cin.ignore();

         mydvd.setMovie(title);
         mydvd.setlength(movieLength);
         mydvd.setYear(yearReleased);

         for (int index = 0; index < quantity; index++)
         {
             cout << "Enter actor #"<< (index + 1) << ": ";
             getline(cin, name,' ');
            // cin.ignore();
             cout << "Enter the name of the character protrayed " << "by actor #" << (index +1) << ": ";
             getline(cin, chName,' ');

             cout << endl;
             mydvd.addActor(name,chName);

         }

cout<<endl<<endl;

return mydvd;

}

void Modify()
{
string moviename;
bool check=false;

cout<<" Enter The Name Of The Movie You Want To Modify. "<<endl;
getline(cin,moviename,' ');
for(int i=0;i<DVD_Collection.size();i++)
   {
if(DVD_Collection[i].getMovie()==moviename)
{
            check=true;
            int quantity;       //to hold number
string name;        //to hold actor name
   string chName;      //to hold name of character
string title;       //to hold movie title
double movieLength; //to hold movie time length
int yearReleased;   // to hold release date

cout<<"     -----Previous Data Of This DVD-----   "<<endl;

DVD_Collection[i].display_DVD();

cout<<" Please Re Input This DVD "<<endl;
         cout <<"Enter the movie title, length, and year released. "
         << "Hit [enter] after each input"<<endl;
         getline(cin,title,' ');
         cin >> movieLength;
         cin >> yearReleased;

         cout << "How many actor names would you like to add to this movie description? ";
         cin >> quantity;
cin.ignore();

         DVD_Collection[i].setMovie(title);
         DVD_Collection[i].setlength(movieLength);
         DVD_Collection[i].setYear(yearReleased);
DVD_Collection[i].actor.clear();
DVD_Collection[i].charName.clear();

         for (int index = 0; index < quantity; index++)
         {
             cout << "Enter actor #"<< (index + 1) << ": ";
             getline(cin, name,' ');
            // cin.ignore();
             cout << "Enter the name of the character protrayed " << "by actor #" << (index +1) << ": ";
             getline(cin, chName,' ');

             cout << endl;
             DVD_Collection[i].addActor(name,chName);

         }

cout<<endl<<endl;
}
}
if(check==false)
cout<<" DVD With This Movie Not Found.."<<endl<<endl;

}

bool REMOVE_DVD()
{
string moviename;

cout<<" Enter The Name Of The Movie You Want To Delete. "<<endl;
getline(cin,moviename,' ');


if(DVD_Collection.empty())
{

cout<<" You have No DVD in your collections "<<endl;
return false;

}

for(int i=0;i<DVD_Collection.size();i++)
{
if(DVD_Collection[i].getMovie()==moviename)
{
DVD_Collection.erase(DVD_Collection.begin()+i);
cout<<" Movie: "<<moviename<<" is no more in Movie Collection! "<<endl;
return true;
}
}

cout<<" Movie with name "<<moviename<<" was not found in the Movie Collection! "<<endl;

return true;
}

void Display_DVD_organizer()
{
system("CLS");
if(DVD_Collection.empty())
{
cout<<" DVD Organizer Is Empty "<<endl;
return;
}
int count=0;

cout<<"                     DVD LIST "<<endl<<endl;

for(int i=0;i<DVD_Collection.size();i++)
{
DVD_Collection[i].display_DVD();

cout<<endl<<"----------------------------------------------------------------------"<<endl;
count++;
}
cout<<endl<<endl<<" TOTAL DVD's ="<<count<<endl<<endl;

}
void menu()
{


   string userOption;
   string userInput;
   bool exitProgram = false;

   while (!exitProgram)
   {
     system("CLS") ;// clears the screen !!
      cout << endl << "                    ";
cout<<"DVD ORGANIZER MAIN MENU" << endl << endl;

      cout << "   1. Add New DVD." << endl;
      cout << "   2. Modify A DVD By Movie Name." << endl;
cout << "   3. Delete A DVD By Movie Name. "<<endl;
      cout << "   4. Display DVD Organizer." << endl;
      cout << endl << " 99. Exit program." << endl << endl;

      cout << "Option> ";
      getline(cin, userOption, ' ');


      switch (atoi(userOption.c_str()))
      {
          case 1:
DVD_Collection.push_back(add_a_dvd());
            break;

          case 2:
system("CLS");
Modify();
   system("Pause");
break;

            case 3:

REMOVE_DVD();

system("Pause");
            break;

case 4:

Display_DVD_organizer();
system("Pause");
break;

            case 99:
             exitProgram = true;
            break;

          default:

            cerr << "Error: unknown option!" << endl;

system("Pause");
            break;
      }
   }

   return;
}

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