1. Finish the following class called Restaurant, this class contains: • Three private instance variables: name(data type

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

1. Finish the following class called Restaurant, this class contains: • Three private instance variables: name(data type

Post by answerhappygod »

1 Finish The Following Class Called Restaurant This Class Contains Three Private Instance Variables Name Data Type 1
1 Finish The Following Class Called Restaurant This Class Contains Three Private Instance Variables Name Data Type 1 (99.37 KiB) Viewed 30 times
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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply