Problem Solving with C++ (10th Edition)
Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 10, Problem 11PP

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)

Implement the class with 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 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 function, getAverage, that returns the average value for all of the movie ratings. Finally, 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.

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.

Blurred answer
Students have asked these similar questions
Given the following data set in the below table, predict the class for the following: • Give birth: yes • Can Fly: no • Live in Water: yes • Have legs: no Name human python salmon whale frog komodo Give Birth yes no no yes no no bat pigeon cat yes leopard shark yes turtle no no penguin porcupine yes no eel salamander no gila monster no platypus no no yes no owl dolphin eagle yes no Can Fly no no no no no no yes yes no no no no no no no no no yes no yes Live in Water Have Legs no no yes yes no no sometimes yes yes yes yes yes no no no no no yes yes no sometimes yes sometimes yes yes no sometimes yes yes yes yes no yes no yes no no no yes no Class mammals non-mammals non-mammals mammals non-mammals non-mammals mammals non-mammals mammals non-mammals non-mammals non-mammals mammals non-mammals non-mammals non-mammals mammals non-mammals mammals non-mammals
class Widget:    """A class representing a simple Widget     === Instance Attributes (the attributes of this class and their types) ===    name: the name of this Widget (str)    cost: the cost of this Widget (int); cost >= 0     === Sample Usage (to help you understand how this class would be used) ===    >>> my_widget = Widget('Puzzle', 15)    >>> my_widget.name    'Puzzle'    >>> my_widget.cost    15    >>> my_widget.is_cheap()    False    >>> your_widget = Widget("Rubik's Cube", 6)    >>> your_widget.name    "Rubik's Cube"    >>> your_widget.cost    6    >>> your_widget.is_cheap()    True    """     # Add your methods here if __name__ == '__main__':    import doctest    # Uncomment the line below if you prefer to test your examples with doctest    # doctest.testmod()
Consider the class Movie that contains information about a movie. The class has the following attributes: . The movie name • The SA Film and Publication Board (FPB) rating (for example, A, PG, 7-9 PG, 10-12 PG, 13, 16, 18, X18, XX) 1 • The number of people that have rated this movie as 1 (Terrible) • The number of people that have rated this movie as 2 (Bad) • The • The • The number of people that have rated this movie as 3 (OK) number of number of people that have rated this movie as 4 (Good) people that have rated this movie as 5 (Great) The class Movie you created, can be implemented more efficiently if we use an array instead of 5 different member variables to count the number of people rating a movie at a specific score. Adjust your class Movie to use an array to count the score ratings for a movie, and test it with the same main function.

Chapter 10 Solutions

Problem Solving with C++ (10th Edition)

Ch. 10.2 - Below we have redefined the class DayOfYear from...Ch. 10.2 - Given the following class definition, write an...Ch. 10.2 - Prob. 13STECh. 10.2 - The private member function DayOfYear::checkDate...Ch. 10.2 - Suppose your program contains the following class...Ch. 10.2 - Suppose you change Self-Test Exercise 15 so that...Ch. 10.2 - Explain what public: and private: do in a class...Ch. 10.2 - a. How many public: sections are required in a...Ch. 10.2 - Give a definition for the function with the...Ch. 10.2 - Give a definition for the function with the...Ch. 10.2 - Give a definition for the function with the...Ch. 10.2 - Suppose your program contains the following class...Ch. 10.2 - How would you change the definition of the class...Ch. 10.2 - Prob. 24STECh. 10.3 - When you define an ADT as a C++ class, should you...Ch. 10.3 - When you define an ADT as a C++ class, what items...Ch. 10.3 - Suppose your friend defines an ADT as a C++ class...Ch. 10.3 - Redo the three- and two-parameter constructors in...Ch. 10.4 - How does inheritance support code reuse and make...Ch. 10.4 - Can a derived class directly access by name a...Ch. 10.4 - Suppose the class SportsCar is a derived class of...Ch. 10 - Solution to Practice Program 10.1 Redefine...Ch. 10 - Redo your definition of the class CDAccount from...Ch. 10 - Define a class for a type called CounterType. An...Ch. 10 - Write a grading program for a class with the...Ch. 10 - Redo Programming Project 1 (or do it for the first...Ch. 10 - Define a class called Month that is an abstract...Ch. 10 - Redefine the implementation of the class Month...Ch. 10 - My mother always took a little red counter to the...Ch. 10 - Write a rational number class. This problem will...Ch. 10 - Define a class called Odometer that will be used...Ch. 10 - Redo Programming Project 7 from Chapter 5 (or do...Ch. 10 - The U.S. Postal Service printed a bar code on...Ch. 10 - Consider a class Movie that contains information...

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
  • Text book image
    EBK JAVA PROGRAMMING
    Computer Science
    ISBN:9781337671385
    Author:FARRELL
    Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
6 Stages of UI Design; Author: DesignerUp;https://www.youtube.com/watch?v=_6Tl2_eM0DE;License: Standard Youtube License