-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResturant.java
More file actions
47 lines (36 loc) · 1.38 KB
/
Resturant.java
File metadata and controls
47 lines (36 loc) · 1.38 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
package com.mycompany.lab55;
public class Restaurant {
public Menu menu;
public Restaurant() {
this.menu = new Menu();
}
public Restaurant(Menu menu) {
this.menu = new Menu(menu.getMeals());
}
public void printRandomMeal() {
Meal[]CURRENT =this.menu.getMeals();
if (CURRENT != null && CURRENT.length > 0) {
int RANDINDX = (int) (Math.random() * CURRENT.length);//بيعطيني حسب طول المصفوفة بين 0-arr.len
Meal RANDMEAL = CURRENT[RANDINDX];
System.out.println("\n--- Random Meal Selected ---");
System.out.println("Code: " + RANDMEAL.getCode());
System.out.println("Name: " + RANDMEAL.name);
System.out.println("Price: " + RANDMEAL.price);
System.out.println("Description: " + RANDMEAL.getDescription());
System.out.println("----------------------------");
} else {
System.out.println("The menu is empty!");
}
}
public Meal getMostExpensiveMeal() {
Meal[] CUR = this.menu.getMeals();
if (CUR == null || CUR.length == 0) return null;
Meal EXP = CUR[0];
for (int i = 1; i < CUR.length; i++) {
if (CUR[i].price > EXP.price) {
EXP = CUR[i];
}
}
return EXP;
}
}