Write a program in C++ unising the following instructions: You are to design a s
ID: 3749878 • Letter: W
Question
Write a program in C++ unising the following instructions:
You are to design a system to keep track of either a CD or DVD/Blu-ray collection. The program will only work exclusively with either CDs or DVDs/Blu-rays since some of the data is different. Which item your program will work with will be up to you. The data will be stored in a file. The data from the file will be stored in a text (.TXT) file as records. Each CD/DVD/Blu-ray in the collection will be represented as a class, so there will be one class that is the CD/DVD/Blu-ray. The CD class will be limited to five (5) songs, and the class will need to keep an array of five (5) strings for the song titles. It should also maintain the length of each song and the total length of the CD, as well as the artist name. The DVD/Blu-ray class will have a data member for the title of the movie, length of the movie, the year of the movie, and for the names of two of the main actors in the movie. There will be a class that maintains the list of CD/DVDs/Blu-rays. This list can be limited to just 5 CD/DVD/Blu-rays and provide a method to add a CD/DVD/Blu-ray, to remove a CD/DVD/Blu-ray, and to update a CD/DVD/Blu-ray.
The program should provide a menu for the user to be able to add, delete, update and display the information in a CD/DVD/Blu-ray. The Course Project must follow standard code formatting, as shown in the textbook code and examples. It must have a comment block at the top of the code file with a detailed description of what the program does. Functions must have a comment block with a detailed description of what it does.
Must follow standard code formatting, as shown in the textbook code and examples. It must include a comment block at the top of the code file with a detailed description of what the program does. Functions must also have a comment block with a detailed description of what it does.
Explanation / Answer
My 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.