Test the class by writing a main method that creates at least two movie objects, adds at least 5 ratings for each movie, and outputs the movie name, MPAA rating, and average rating for each movie object.

Consider a class Movie that contains information about a movie. The class has the following attributes:
• The movie name
• The MPAA rating (e.g. 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 accessors and mutators for the movie name and MPAA rating. Write a method addRating that takes an integer as an input parameter. The method 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 incremented by one. Write another method, getAverage, that returns the average value for all of the movie ratings.

his is much more scalable using arrays and this problem is re-visited in Chapter 7.


See the code in Movie.java.

Computer Science & Information Technology

You might also like to view...

In a single result function, the executable statements include a _____ statement that communicates the result back to the statement that called the function.

a. header b. type definition c. parameter d. return

Computer Science & Information Technology

Write a method for Turtle to draw a pentagon. Pass in the length of the sides.

What will be an ideal response?

Computer Science & Information Technology

When copying or cutting a range of cells, the range is:

A) surrounded by a moving dashed green border. B) surrounded by a solid black border. C) surrounded by a moving dashed black border. D) surrounded by a solid green border.

Computer Science & Information Technology

Folders automatically shared with the network in Windows 8.1 are __________

a. Only the Public folder and default administrative shares b. Only the hidden share C$ c. Only default administrative shares d. Only the Public folder

Computer Science & Information Technology