Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement in c++ 3. (4 pts) Define and implement the following class. Create a class Movie that contains information about a movie. The class has

Implement in c++ image text in transcribed
3. (4 pts) Define and implement the following class. Create a class Movie that contains information about a movie. The class has the following attributes. a. The name of the movie b. The MPAA rating (for example, G, PG, PG-13, and R) c. The number of people that have rated this movie as a 1 (Terrible) d. The number of people that have rated this movie as a 2 (Bad) The number of people that have rated this movie as a 3 (OK) f. The number of people that have rated this movie as a 4 (Good) The number of people that have rated this movie as a 5 (Great) g. h. The average rating, which is calculated from the above 5 ratings. We are designing the class using the ADT (abstract data type) principle. The member variables movie name and ratings need to be private. Implement the class with accessor and mutator member functions for the movie name and rating. Write a public member function addRating that takes an integer as an input parameter. The member function addRating should verify that the parameter is a number between 1 and 5, and if so, increment the number of people rating the movie that match the input parameter. For example, if 3 is the input parameter, then the number of people that rated the movie as a 3 should be incremented by 1. Write another member function, getAverage, that returns the average value for all of the movie ratings. In addition, add a constructor that allows the programmer to create the object with a specified name and MPAA rating. The number of people rating the movie should be set to 0 in the constructor. that compares the average rating Finally, write an overloaded operator of two Movie objects. If the average values are the same, it returns true, otherwise, false. You can implement the operator either as a friend function or as a member function. If you don't know how to do it, you can opt to implement a normal function compare which does the same (but with some small penalty of the mark) Test the class by writing a function that creates at least two movie objects, adds at least five ratings for each movie, and outputs the movie name, MPAA rating, and average rating for each movie object. Then compare the objects

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Modeling And Design

Authors: Toby J. Teorey, Sam S. Lightstone, Tom Nadeau, H.V. Jagadish

5th Edition

0123820200, 978-0123820204

More Books

Students also viewed these Databases questions

Question

How do modern Dashboards differ from earlier implementations?

Answered: 1 week ago