Question: MEDIA INHERITANCE - C++ You will create an inheritance set of classes. Use proper rules for data types, class definitions, and inheritance (check input/output of

MEDIA INHERITANCE - C++

You will create an inheritance set of classes. Use proper rules for data types, class definitions, and inheritance (check input/output of data below). You will create a super media class that will define a general form of media. A media properties will consist of the name and price. The media should be able to construct itself out of the arguments sent to it, virtually print both data fields labeled (price to two decimal places) and overload the < operator to compare two medias by comparing their name field.

You will then create two subclasses of media for a movie and a book. A movie "is a" media, but also has a rating. It also should construct itself by initializing all data fields, but use the super media constructor to initialize the inherited data fields. It will also override the media print function. In the new version, it should print that it is a movie, then call the super print function to print the name and price, then print the new labeled rating data field itself.

A book "is a" media, but also has an author and will be set up similar to a movie. It also should override the media print function. In the new version, it should print that it is a book, then call the super print function to print the name and price, then print the new labeled author data field itself.

You will then create a main class that will declare an array of three super media pointers (so you can combine movies and books together in the array). Then using a loop, prompt and input all the data fields (asking the user what kind of media for what added data to input). At the end of the loop, construct the next (proper type) object and assign it into the array. Put a blank line between prompts for the input objects.

When the input loop is over, call a function in the main program that will selection sort the array of media pointers. Use the overloaded < operator to perform the sort on the name field of the calling object.

In a separate loop, call the print function (with dynamic binding!). Put a blank line between output objects.

Run your program with the data below and create the output as shown below. Submit your three class definitions, main program, and output text file. Document all files with at least 4 lines of comments at the top and at least 5 comments throughout the code for all of the not easily understandable lines of code.

MEDIA INHERITANCE - DATA

Input:

Enter name: Planet of the Apes

Enter price: 8.90

Is media a book(b) or movie(m): m

Enter rating: G

Enter name: Back to the Future

Enter price: 13.90

Is media a book(b) or movie(m): m

Enter rating: PG

Enter name: Intensity

Enter price: 7.90

Is media a book(b) or movie(m): b

Enter author: Dean Koontz

Output:

Movie

Name is Back to the Future

Price is 13.90

Rating is PG

Book

Name is Intensity

Price is 7.90

Author is Dean Koontz

Movie

Name is Planet of the Apes

Price is 8.90

Rating is G

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!