1. Finish the following classcalled Restaurant, this class contains:
Definitions of three private instance variables anddefault constructor are given. You are supposed to implement thesecond constructor and three public methods.
public class Restaurant
{
private String name;
private double rating;
private String address;
public Restaurant( ) { }
//1.1implementation of getter: String getAddress(),put your codesin the answer area (3 points)
//1.2 implementation of setter setName(Stringname), 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 StringgetRatingString(), put your codes in the answer area (6points)
}//end of Restaurant class
2. Create an object to test the secondConstructor and public methods. (6points)
Assume we have a restaurant: address is "100 west st", name is“Seafood Restaurant” and rating is 9.5. Print the restaurant'srating string after creating an object of this restaurant.
public static void main()
{
//2. put your codes in the answerarea
}
1. Finish the following class called Restaurant, this class contains: Definitions of three private instance variables an
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am