Create a c++ class entertainment consisting of the following data members:
• Title
• Air_Date i.e. Release Date
• Genre
• Type (i.e. Movie, TV Show)
• Runtime
• Country
• Actors
• Rating.
Follow the instructions below for creating the class and objects: Store the owners name as a dynamic array data member.
• Store the genre as a dynamic array data member.
• Store the names of the actors as a dynamic array data member.
• Create an object named “obj1” and initialize the object.
• Create a copy constructor that can list of genre, country and rating.
• Generate another object named “obj2” that is created by copying only the genre, country and ratings from “obj1”.
• Initialize the remaining attributes with values of your own.
#include<iostream>
#include <stdio.h>
using namespace std;
class entertainment{
public:
string title;
int date;
string type;
string country;
int rating;
void input()
{
cout<<"Enter Title"<<endl;
cin>>title;
cout<<"Enter date of release"<<endl;
cin>>date;
cout<<"Enter Genre type"<<endl;
cin>>type;
cout<<"Enter Runtime country"<<endl;
cin>>country;
cout<<"Enter actors rating"<<endl;
cin>>rating;
}
void display()
{
cout<<"Title : "<<title<<endl;
cout<<"Air Date : "<<date<<endl;
cout<<"Genre Type : "<<type<<endl;
cout<<"Runtime Country : "<<country<<endl;
cout<<"Actors Rating : "<<rating<<endl;
}
};
int main()
{
int n;
cout<<"Enter value of n"<<endl;
cin>>n;
entertainment e[n];
for(int i=0; i<n; i++)
{
e[i].input();
cout<<endl;
}
cout<<endl<<endl;
cout<<"Display of Entertainment info"<<endl;
cout<<"----------------------------------"<<endl;
for(int i=0; i<n; i++)
{
e[i].display();
cout<<endl<<endl;
}
}
Comments
Leave a comment