forked from oleksandr-kazimirov/pointer-enum
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFruitMarket.java
More file actions
57 lines (38 loc) · 1.19 KB
/
FruitMarket.java
File metadata and controls
57 lines (38 loc) · 1.19 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
public enum FruitMarket {
APPLE("Apple", 100, 0.5),
ORANGE("Orange", 50, 2.2),
BANANA("Banana", 200, 1.5),
APRICOT("Apricot", 340, 2.5),
KIWI("Kiwi", 85, 3),
LEMON("Lemon", 98, 0.8),
MANGO("Mango", 120, 3.6);
private String fruits;
private float quantity;
private double price;
FruitMarket(String fruits, float quantity, double price) {
this.fruits = fruits;
this.quantity = quantity;
this.price = price;
}
public String toString() {
return fruits;
}
static void showFruits() {
for (FruitMarket fruits : FruitMarket.values()) {
System.out.println(fruits.name());
}
}
static void showChosenFruit(FruitMarket fruits) {
switch (fruits) {
case APPLE:
case ORANGE:
case BANANA:
case APRICOT:
case KIWI:
case LEMON:
case MANGO:
System.out.println(" You picked " + fruits.toString() + ", we have " + fruits.quantity + "(kg.) our price:" + fruits.price + "$ per(kg.) ");
break;
}
}
}