Consider a class RatingScore that represents a numeric rating for something such as a movie. Its attributes are

• A description of what is being rated
• The maximum possible rating
• The rating
It will have methods to
• Get the rating from a user
• Return the maximum rating possible
• Return the rating
• Return a string showing the rating in a format suitable for display
a. Write a method heading for each method.
b. Write preconditions and postconditions for each method.
c. Write some Java statements that test the class.
d. Implement the class.


a) ```
public void inputRating()
public int getMaxRating()
public int getRating()
public String getRatingString()
```

b)
public void inputRating()
Precondition: maximum rating is positive.
Postcondition: A value for the rating was obtained from the user. The rating was greater than or equal to zero and less than or equal to the maximum possible rating. The rating attribute was changed to the value obtained from the user.

public int getMaxRating()
Precondition: none.
Postcondition: The maximum rating was returned.

public int getRating()
Precondition: none.
Postcondition: The rating was returned.

public String getRatingString()
Precondition: none.
Postcondition: The rating was returned in some nicely formatted string.

c&d)
See the code in RatingScore.java.

Computer Science & Information Technology

You might also like to view...

The C++11 _________ algorithm locates both the smallest and largest elements in a range.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

The Internet of Things pertains to the connection of the physical world to the Internet

Indicate whether the statement is true or false

Computer Science & Information Technology

The C programming language is considered what type of language?

A. Object-oriented (OO) B. Scripting C. Event-driven D. Procedural

Computer Science & Information Technology

What step in the laser printing process is responsible for conditioning the imaging drum in preparation for receiving an electrical charge?

A. Charging B. Cleaning C. Transferring D. Fusing

Computer Science & Information Technology