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
Question
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
Solution
Here is the C++ code that defines the class Movie and includes the required functions:
#include <iostream>
#include <string>
using namespace std;
class Movie {
private:
string title;
int year;
string director;
public:
void setTitle(string t) {
title = t;
}
void setYear(int y) {
year = y;
}
void setDirector(string d) {
director = d;
}
void displayInfo() {
cout << "Title: " << title << endl;
cout << "Year: " << year << endl;
cout << "Director: " << director << endl;
}
};
int main() {
Movie myFavoriteMovie;
myFavoriteMovie.setTitle("Inception");
myFavoriteMovie.setYear(2010);
myFavoriteMovie.setDirector("Christopher Nolan");
myFavoriteMovie.displayInfo();
return 0;
}
This code first defines the class Movie with private fields for the title, year, and director. It then includes public functions to set these fields. The displayInfo() function is used to print out the information about the movie. In the main() function, a Movie object named myFavoriteMovie is declared and its fields are set using the public functions. Finally, the information about myFavoriteMovie is printed out using the displayInfo() function.
Similar Questions
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++
Insert a new field called ‘Movie’ to display the results of concatenating the ‘Title’ and‘Director’ fields. Add a ‘: Directed by ’ text string in the middle of concatenate formulaas well
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 the titles of all movies directed by 'Martin Scorsese' from the Movie Database.Your task is to identify and display the movies associated with the director with the name 'Martin Scorsese.'The following table is already created, and the records are inserted into the table.
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 the titles of all movies directed by 'Martin Scorsese' from the Movie Database.Your task is to identify and display the movies associated with the director with the name 'Martin Scorsese.'The following table is already created, and the records are inserted into the table.Table Details:
How do titles and credits let you enhance your movie?Collections pane of Windows Movie MakerSmaller segments of larger audio and video filesThe video transitions folder in the Collections paneBy adding text-based information to your movie
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.