Question: In C + + : Objective: User - defined Classes, Public and Private members, Constructors, Getter and Setter Functions Consider a class Movie that contains
In C:
Objective: Userdefined 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 R
The number of people that have rated this movie as a Terrible
The number of people that have rated this movie as a Bad
The number of people that have rated this movie as a OK
The number of people that have rated this movie as a Good
The number of people that have rated this movie as a 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 addrating that takes an integer as an input parameter. The function should verify
that the parameter is a number between and and if so increment the number of people rating
the movie that matches the input parameter. For example, if is the input parameter, then the
number of people that rated the movie as a should be increased by
Write another function, averagerating, 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 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.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
