Question: Class _ Method Part 1 Write down the code for creating a class, Restaurant, It should have the following functionality. Data An instance variable, name,
ClassMethod
Part
Write down the code for creating a class, Restaurant, It should have the following functionality.
Data
An instance variable, name, of type String
An instance variable, rate, of type int
Method
A constructor without any parameters, that initialize above variables.
Another constructor that initializes the above variables with arguments received by class user.
Methods that return the value of defined variables.
Methods that set the value of above variables.
Part
Now, add the main method.
Create instances of the class Restaurant.
Call set and get methods for these objects.
After your program is finished, copy and paste the program output below.
import java.util.;
public class Restaurant
private String name ;
private int rate ;
constructor
public Restaurant
name No Name";
rate ;
xxx your codes
public static void mainString args
Restaurant A new Restaurant;
Restaurant B new RestaurantmyRes;
List arr Arrays.asList A B ;
for Restaurant r: arr
int rate rgetRate;
String name rgetName;
System.out.printlnratename;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
