-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestaurant.java
More file actions
102 lines (85 loc) · 2.81 KB
/
Restaurant.java
File metadata and controls
102 lines (85 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
public class Restaurant {
private String name;
private String address;
private int rating;
private int capacity;
private String[] menu;
public Restaurant() {
this.name = "HappyRestaurant";
this.address = "Jayanagar";
this.rating = 5;
this.capacity = 30;
this.menu = new String[]{"Burger", "Pizza", "Cheese rolls"};
}
public Restaurant(String name, String address, int rating, int capacity, String[] menu) {
this.name = name;
this.address = address;
this.rating = rating;
this.capacity = capacity;
this.menu = menu;
}
public void setName(String name) {
this.name = name;
}
public void setAddress(String address) {
this.address = address;
}
public void setRating(int rating) {
this.rating = rating;
}
public void setCapacity(int capacity) {
this.capacity = capacity;
}
public void setMenu(String[] menu) {
this.menu = menu;
}
public String getName() {
return this.name;
}
public String getAddress() {
return this.address;
}
public int getRating() {
return this.rating;
}
public int getCapacity() {
return this.capacity;
}
public String[] getMenu() {
return this.menu;
}
public void printDetails() {
System.out.println("Name: " + this.name);
System.out.println("Address: " + this.address);
System.out.println("Rating: " + this.rating);
System.out.println("Capacity: " + this.capacity);
System.out.println("Menu: ");
for (String item : this.menu) {
System.out.println("- " + item);
}
}
public void printDetails(String message) {
System.out.println(message);
this.printDetails();
}
public void printDetails(String message, boolean showMenu) {
System.out.println(message);
System.out.println("Name: " + this.name);
System.out.println("Address: " + this.address);
System.out.println("Rating: " + this.rating);
System.out.println("Capacity: " + this.capacity);
if (showMenu) {
System.out.println("Menu: ");
for (String item : this.menu) {
System.out.println("- " + item);
}
}
}
public static void main(String[] args) {
String[] menu = new String[]{"Rice Sambar", "Idli", "Vada"};
Restaurant restaurant1 = new Restaurant();
restaurant1.printDetails("Default Restaurant Details:");
Restaurant restaurant2 = new Restaurant("MyRestaurant", "Koramangala", 4, 50, menu);
restaurant2.printDetails("My Restaurant Details:", true);
}
}