Answer to Question #264886 in C++ for sam

Question #264886

Q#3)a. Define a class named Movie. Include private fields for the title, year, and name of the director.

Include three public functions with the prototypes

void Movie::setTitle(string);

void Movie::setYear(int);

void Movie::setDirector(string);

Include another function that displays all the information about a Movie.

b. Include a function which accepts 2 objects of type Movie and displays whether or not they were

released in the same year and also whether the Directors are same. String functions may be used.


1
Expert's answer
2021-11-12T07:16:19-0500
#include<iostream>
using namespace std;
class Movie{
	
	private :
		string title, director;
		int year;
	public:
		
	void setTitle(string t){
title = t;


	}


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


void setDirector(string d){
	director = d;
}


void display(){
	cout<<"The title is: "<<title<<"\nThe director is: "<<director<<"\nThe year released is:  "<<year<<endl;
}


void check(Movie d){
	if(year==d.year){
		cout<<"The movies were released in the same year\n";
	}
	else{
		cout<<"The movies were not released in the same year\n";
	}
}
};
int main(){
	Movie m1, m2;
	m1.setTitle("Bad girl");
	m1.setDirector("Michael");
	m1.setYear(2021);
	m2.setTitle("Prison Break");
	m2.setDirector("Lincoln");
	m2.setYear(2021);
	m1.check(m2);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS