1. Finish the following class called Restaurant, this class contains: • Three private instance variables: name(data type
Posted: Fri Jul 08, 2022 7:27 am
1. Finish the following class called Restaurant, this class contains: • Three private instance variables: name(data type: String), rating(data type: double) and address(data type: String); • Default constructor • Second constructor: has three parameters, these three parameters can initialize name, rating and address as specified • Three public methods: • String getAddress(): a public method for retrieving a restaurant's address; • setName (String n): a public method that sets the name of a restaurant. • String getRatingString(): a public method that returns a restaurant's rating String: ▪ returns "Best Choice" if a restaurant's rating is >= 9.5 ▪ returns "Great" if a restaurant's rating is >=8.5 and < 9.5 ▪ returns "Good" if a restaurant's rating is >=0 and < 8.5 Definitions of three private instance variables and default constructor are given. You are supposed to implement the second constructor and three public methods. public class Restaurant { { private String name; } private double rating; private String address; public Restaurant ( ) { //1.1 implementation of getter: String getAddress (), put your codes in the answer area (3 points) //1.2 implementation of setter setName (String name), put your codes in the answer area (3 points) //1.3 implementation of the second Constructor, put your codes in the answer area (3 points) //1.4 implementation of method String getRatingString(), put your codes in the answer area (6 points) }//end of Restaurant class 2. Create an object to test the second Constructor and public methods. (6 points) Assume we have a restaurant: address is "100 west st", name is "Seafood Restaurant" and rating is 9.5. Print the restaurant's rating string after creating an object of this restaurant. public static void main() } //2. put your codes in the answer area