Create a class named MovieManagementSystem (MMS) with the following data members: MovieName, MovieRating (which could be "under 13", "PG", etc.), and MovieComments. The MovieName and MovieRating should be fixed by the programmer using constructor and mutator functions (setter ()) for 10 movies. Implement functionality to save this data in a "MMS.txt" file. Additionally, prompt the user to provide comments for the movies and store those comments in the data member MovieComments, saving them in a "Comments.txt" file along with MovieName. For comment purposes, show the contents of "MMS.txt" to the user and take his comments/opinions about any movie of his choice. You can take/save comments on movies having fewer than 5 comments overall. In the end, Display the Content of Both files on the screen if the user wants to see the data. (Use a Menu-driven Program). C++
Question
Create a class named MovieManagementSystem (MMS) with the following data members: MovieName, MovieRating (which could be "under 13", "PG", etc.), and MovieComments. The MovieName and MovieRating should be fixed by the programmer using constructor and mutator functions (setter ()) for 10 movies. Implement functionality to save this data in a "MMS.txt" file. Additionally, prompt the user to provide comments for the movies and store those comments in the data member MovieComments, saving them in a "Comments.txt" file along with MovieName. For comment purposes, show the contents of "MMS.txt" to the user and take his comments/opinions about any movie of his choice. You can take/save comments on movies having fewer than 5 comments overall. In the end, Display the Content of Both files on the screen if the user wants to see the data. (Use a Menu-driven Program). C++
Solution
Here is a basic implementation of the MovieManagementSystem (MMS) class in C++. This code does not include error checking and exception handling for the sake of simplicity.
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
class Movie {
public:
std::string MovieName;
std::string MovieRating;
std::vector<std::string> MovieComments;
Movie(std::string name, std::string rating) {
MovieName = name;
MovieRating = rating;
}
void addComment(std::string comment) {
if (MovieComments.size() < 5) {
MovieComments.push_back(comment);
}
}
};
class MovieManagementSystem {
public:
std::vector<Movie> movies;
void addMovie(Movie movie) {
movies.push_back(movie);
}
void saveMovies() {
std::ofstream file("MMS.txt");
for (Movie movie : movies) {
file << movie.MovieName << "," << movie.MovieRating << "\n";
}
file.close();
}
void saveComments() {
std::ofstream file("Comments.txt");
for (Movie movie : movies) {
for (std::string comment : movie.MovieComments) {
file << movie.MovieName << "," << comment << "\n";
}
}
file.close();
}
void displayMovies() {
std::ifstream file("MMS.txt");
std::string line;
while (std::getline(file, line)) {
std::cout << line << "\n";
}
file.close();
}
void displayComments() {
std::ifstream file("Comments.txt");
std::string line;
while (std::getline(file, line)) {
std::cout << line << "\n";
}
file.close();
}
};
int main() {
MovieManagementSystem mms;
// Add movies here
// mms.addMovie(Movie("Movie1", "PG"));
// mms.addMovie(Movie("Movie2", "under 13"));
// Save movies and comments to file
mms.saveMovies();
mms.saveComments();
// Display movies and comments
mms.displayMovies();
mms.displayComments();
return 0;
}
This code creates a Movie class with MovieName, MovieRating, and MovieComments as members. The MovieManagementSystem class manages a list of movies, and provides methods to save the movies and comments to files, and to display the contents of these files.
In the main function, you can add movies to the MovieManagementSystem, save the movies and comments to files, and display the contents of these files.
Similar Questions
Define a class named Movie. Include private fields for the title, year, and name of the director.Include three public functions with the prototypesvoid Movie::setTitle(string);,void Movie::setYear(int);, andvoid setDirector(string);.Include another function that displays all the information about a Movie.Write a main()function that declares a movie object named myFavoriteMovie.Input:Inception2010Christopher NolanOutput:Title: InceptionYear: 2010Director: Christopher NolanInput
Given a database for a movie production company. The database includes information about actors, directors, movies, movie cast, and ratings. Write a query to retrieve a list of actors who have participated in movies either before the year 2005 or after the year 2015. The data is stored in a prepopulated database with tables for actors, directors, movies, movie casts, and ratings
You are managing a database for a movie production company. The database includes information about actors, directors, movies, movie cast, and ratings.Write a query for updating the ratings of all movies directed by 'Lankesh' to a new rating of 3 in a database that contains information about actors, directors, movies, movie casts, and ratings.The following table is already created, and the records are inserted into the table.
A movie company like Netflix will use more volumes of data for movie provisions becausethey will want to personalize movies for different countriesthey will want to save costs by not producing movies users are interested inthey will want to share user datathey have diverse users and will need to personalize movie content based on user interests
Sarah, a reviewer for MovieMania Reviews, is updating the database with recent ratings and reviews for the film 'Tenet' directed by Christopher Nolan.Create a program that records and displays the rating and review details for the movie.Input format :The first line of input consists of an integer N, representing the movie rating (1 to 5 stars).The second line consists of a string containing the review text.Output format :The first line of output prints "Recent Review Rating: [N] stars"The second line prints "Review Details: " followed by the review text.Refer to the sample output for formatting specifications.Code constraints :1 ≤ N ≤ 5Sample test cases :Input 1 :4The movie has a complex narrative but is visually stunning.Output 1 :Recent Review Rating: 4 starsReview Details: The movie has a complex narrative but is visually stunning.Input 2 :5An incredible film with mind-blowing sequences and outstanding performances.Output 2 :Recent Review Rating: 5 starsReview Details: An incredible film wit
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.