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

Hello, I need some help with an C++ program. This program will allow the user to

ID: 3570850 • Letter: H

Question

Hello, I need some help with an C++ program.

This program will allow the user to keep track of a DVD collection. Each DVD in the collection will be represented as a class, so you will have one class that is a single DVD.

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 DVDs. This list will be a vector of that class type. The program must provide methods (functions) to add a DVD, remove a DVD and update a DVD. There should also be a function that displays the entire list of 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.

Here's some of the code that I have been working on:


#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include "DVD.h"

using namespace std;

class DVD
{
private:
   string movieTitle;
   string name;
   string charName;
   double movieLength;
   int movieYear;
public:
   DVD(){


       movieTitle = "";

       movieLength = 0;

       movieYear = 0;

   }

   DVD(string n)
   {
       name = n;
   }

   void setTitle(string t)
   {
       movieTitle = t;
   }

   void setLength(double l)
   {
       movieLength = l;
   }

   void setYear(int y)
   {
       movieYear = y;
   }

   string getName()
   {
       return name;
   }

   string getTitle()
   {
       return movieTitle;
   }

   double getLength()
   {
       return movieLength;
   }

   int getYear()
   {
       return movieYear;
   }


};

int showMenu()

{

   cout << "Welcome to the DVD Collection Program! What do you want to do? " << 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;

   int c;

   cin >> c;

   return c;

}

void list(vector<DVD> &vectorName, vector<string>&vectorCharName, DVD *mydvd)
{
   const int ARRAY=2;
   /*DVD mydvd[ARRAY];*/
  

   for (int i = 0; i < 1; i++)
   {


       //table format
       cout << setw(10) << " Movie Title: "
           << setw(10) << "Length:"
           << setw(10) << "Year: "
           << setw(10) << "Actors/Actresses:"
           << setw(10) << "Characters: " << endl;

       cout << "------------------------------------------------------------ ";


cout <<setw(10)<< right << mydvd[i].getTitle()
       <<setw(10)   << mydvd[i].getLength()
           << setw(10) << mydvd[i].getYear();

       for (std::size_t i = 0; i < vectorName.size(); i++)
       {

           cout<< setw(10) << vectorName[i].getName()
               <<setw(10)<< vectorCharName[i] << endl ;

       }

       cout << " " << endl;

   }
}

int main()
{
   const int ARRAY = 2;
   DVD mydvd[ARRAY];

   vector<DVD> vectorList;
   vector<DVD> vectorName;
   vector<string> vectorCharName;

   string actor, character, title;
   double length;
   int year;
   int quantity;
   int ch;


   // Constants for menu choices

   const int SHOW_LIST = 1, ADD_DVD = 2, REMOVE_DVD = 3, UPDATE_DVD = 4, QUIT_CHOICE = 5;

   while (1){

       ch = showMenu();

       for (int i = 0; i < 1; i++){

           if (ch == 1){

               // Ask the user to enter the details of DVD


               cout << "Enter the movie title, length, and year released. "

                   << "Hit [ENTER] after each input: ";


               cin >> title;

               cin >> length;

               cin >> year;

               cout << endl;

               cout << " How many actors? ";
               cin >> quantity;

               for (int i = 0; i < quantity; i++)
               {
                   cout << "Actor " << (i + 1) << ": ";
                   cin.ignore();
                   getline(cin, actor); // get user input
                   cout << "Character " << ": ";
                   getline(cin, character); // get user input
                   vectorName.push_back(actor);
                   vectorCharName.push_back(character);
               }


               // Store the DVD details


               mydvd[i].setTitle(title);
               mydvd[i].setLength(length);
               mydvd[i].setYear(year);

               list(vectorName, vectorCharName, mydvd);
           }

           else if (ch == 4)

           {

               list(vectorName, vectorCharName, mydvd); // displays dvd list

           }

           else if (ch == 5)

               exit(0);

           else if (ch == 3)
           {
               list(vectorName, vectorCharName, mydvd); // displays dvd list

               int sn;

               cout << "Enter serial number of dvd(starting from 1 ) you wish to update :";
               cin >> sn;
               cout << "Enter the movie title, length, and year released. "

                   << "Hit [ENTER] after each input: ";

               cin >> title;

               cin >> length;

               cin >> year;


               cout << " The DVD is now updated ";

               // Store the DVD details

               mydvd[sn - 1].setTitle(title);

               mydvd[sn - 1].setLength(length);

               mydvd[sn - 1].setYear(year);


           }

           else if (ch == 2) // removes a dvd
           {
               int sn;

               cout << "Enter serial number of dvd(starting from 1 ) you wish to update :";
               cin >> sn;
              
               cout << "Enter the movie title, length, and year of the DVD, you would like to removed. "

                   << "Hit [ENTER] after each input: ";

               cin >> title;

               cin >> length;

               cin >> year;

               // Store the DVD details

               mydvd[i].setTitle(title);

               mydvd[i].setLength(length);

               mydvd[i].setYear(year);

cout << " The DVD is now Remove ";
           }
       }
   }
   return 0;
}

Some how i can't delete DVD's or update DVD's properly.

Any help will be appreciated.

Explanation / Answer

You Can use this code but replace with your requirement

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