Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Rater class represents a rating system for a company. The company is rated on a scale of 1-5. The toString representation changes based on

image text in transcribed

image text in transcribed

The Rater class represents a rating system for a company. The company is rated on a scale of 1-5. The toString representation changes based on how well rated the company is. Suppose we have a company called Tina's Tires. If its rating is less than two, toString would return Not Recommended Company Tina's Tires If its rating is over 3.5, toString would return Gold Star Company Tina's Tires Otherwise, toString would return "Well Rated Company Tina's Tires" Remember, once a return statement is executed, the rest of the method is skipped. Therefore, if you return a String in an if statement, the remaining if statements will not be tested. The other method you need to fill in is setRating. The rating should only be changed if the new rating is 5 or less. After you fill in Rating, main should produce the following output. Note that main runs several test cases to check all of the conditions of the program! We need to make sure to test every line of code! Current Rating: 2.0 Well Rated Company Jr Cookery Current Rating: 4.5 Gold Star Company Jr Cookery Current Rating: 4.5 Gold Star Company Jr Cookery Current Rating: 1.0 Not Recommended Company Jr Cookery Let's look at the Rater class again. The Rater class represents a rating system for a company. The company is rated on a scale of 1-5. This time, there is an additional instance variable - review. This variable is set based on the company's current rating. The updateReview method updates review. If the company is rated 3 or more, the company's review would say "Proudly recommended". Otherwise, the review will say, "Needs more ratings" The toString method returns the name of the company followed by its review. For example, it might say Tina's Tires : Proudly recommended. Update the toString method to match that format. The last method you need to fill in is setRating. The rating should only be changed if the new rating is 5 or less. This is the same as the last time you saw this class. Main In main, create a Rater object. Set its rating to something less than 3. Call updateReview, then print out the object. Use setRating to set the rating to something between 3 and 5. Call updateReview again, then print out the object. This will let you test both branches of your if-else statement! If you'd like to look at the code that you wrote from the previous assignment you can go here: https://codehs.com/editor/1722952/6165/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions