-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTeh.java
32 lines (27 loc) · 975 Bytes
/
Teh.java
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
package cafe_kasir;
import javax.swing.JOptionPane;
public class Teh extends Minuman {
private String fruit;
String[] fruits = {"Lemon", "Lychee"};
public Teh(String size, int amount, Cafe_kasir lbl) {
super(size, amount);
try {
fruit = (String) JOptionPane.showInputDialog(lbl, "Select a fruit.", "Select a fruit",
JOptionPane.QUESTION_MESSAGE, null, fruits, fruits[0]);
double price;
price = switch (size) {
case "Small" -> 4000;
case "Medium" -> 5000;
default -> 6000;
};
if (fruit.equalsIgnoreCase("Lemon")) price += 3000;
if (fruit.equalsIgnoreCase("Lychee")) price += 5000;
setPrice(price);
} catch (NullPointerException e) {
}
}
@Override
public String toString() {
return super.toString() + fruit + " Tea ";
}
}