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

Objective: Write a program that manages a Movie database. Requirements: Each mov

ID: 3761575 • Letter: O

Question

Objective:

Write a program that manages a Movie database.

Requirements:

Each movie needs to have the follow attributes:

Name

Year

Rating (1 to 5 stars)

Director

Box Office Gross

The Movie database must be able to

Add a movie

Remove a movie by title

Sort movie by Title

Sort movie by Rating

Sort movie by Box Office Gross

Sort movies by a director (LastName)

Print to a database file (you may define your own protocol)

Read from a database file

Write a front end that will allow a user to use any of the features noted in the database description

(Please separate the code that you post so that I know where a new class begins, Thank you!)

Explanation / Answer

#include <iostream>
#include <string>
#include "MovieType.h"
using namespace std;
ostream& operator<< (ostream& osObject, const MovieType& name)
{
osObject << name.MovieNameList << year.MovieYearList;
return osObject;
}
istream& operator>> (istream& isObject, MovieType& name)
{
isObject >> name.MovieNameList >> year.MovieYearList;
return isObject;
}
void MovieType::print() const
{
cout << MovieName << " " << MovieYear << endl;
}
void MovieType::setName(string name)
{
MovieName = name;
MovieYear = year;
}
string MovieType::getMovieNameList() const
{
return MovieName;
}
string MovieType::getMovieYearList() const
{
return year;
}
//constructor
MovieType::MovieType(string name, string year)
{
MovieName = name;
MovieYear = year;
}

//Program: Sales data analysis
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
struct MovieLibrary
{
string MovieNameList; //name of Movie
string starNameList; //name of star of Movie
int MovieYearList; //year Movie released
string upcomingReleases; //projected releases to add to Movie collection
};

int main()
{
//Step 1
ifstream infile; //input file stream variable
ofstream outfile; //output file stream variable
string inputFile; //variable to hold the input file name
string outputFile; //variable to hold the output file name

cout << "Enter the Movie name: "; //Step 2
cin >> inputFile; //Step 3
cout << endl;
infile.open(inputFile.c_str()); //Step 4
if (!infile) //Step 5
{
cout << "Cannot open the input file."
<< endl;
return 1;
}
initialize(infile, MovieNameList); //Step 6
infile.close(); //Step 7
infile.clear(); //Step 7
cout << "Enter the stars name: "; //Step 8
cin >> inputFile; //Step 9
cout << endl;
infile.open(inputFile.c_str()); //Step 10
if (!infile) //Step 11
{
cout << "Cannot open the input file."
<< endl;
return 1;
}
outfile.open(outputFile.c_str()); //Step 14
outfile << fixed << showpoint
<< setprecision(2); //Step 15
MovieNameList(infile, MovieNameList); //Step 16
starName(starNameList); //Step 17
MovieYear(MovieYearList);
starName(outfile, starNameList); //Step 20
MovieYear(outfile, MovieYearList); //Step 21

infile.close(); //Step 22
outfile.close(); //Step 22
return 0;
}

#ifndef H_MovieType
#define H_MovieType
#include <string>

using namespace std;
class MovieType
{
friend ostream& operator<< (ostream&, const MovieType &);
friend istream& operator>> (istream&, MovieType &);
public:
void print() const;
//Function to output the first name and last name
//in the form firstName lastName.

void setName(string);
//Function to set MovieName according
//to the parameters.
//Postcondition: MovieName = name.
string getMovieNameList() const;
//Function to return the name list.
//Postcondition: The value of the nameList is returned.
string getMovieYearList() const;
//Function to return the year of the Movie.
//Postcondition: The value of the MovieYear is returned.
MovieType(string name = "", string year = "");
//constructor
//Sets Name and year according to the parameters.
//The default values of the parameters are empty strings.
//Postcondition: nameList = name; yearList = year
private:
string nameList; //variable to store the first name
string yearList; //variable to store the last name
};
#endif