Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C + + : Objective: User - defined Classes, Public and Private members, Constructors, Getter and Setter Functions Consider a class Movie that contains

In C++:
Objective: User-defined Classes, Public and Private members, Constructors, Getter and Setter
Functions
Consider a class Movie that contains information about a movie. The class has the following
attributes:
The movie name
The MPAA rating (for example, G, PG, PG-13, R)
The number of people that have rated this movie as a 1(Terrible)
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)
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)
These attributes can be defined as private member variables inside the class.
Next declare and later define the following procedural attributes as public members:
Implement the accessor and mutator functions for the movie name and MPAA rating.
Write a function add_rating that takes an integer as an input parameter. The function should verify
that the parameter is a number between 1 and 5, and if so, increment the number of people rating
the movie that matches 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 increased by 1.
Write another function, average_rating, that returns the average value for all of the movie ratings.
Also, 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.
Finally, test the class by writing a main 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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

Window 1 0 is wquipped with internet explorer 1 1 true or false

Answered: 1 week ago