forked from Yandex-Practicum/Java-Module-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDish.java
More file actions
29 lines (25 loc) · 836 Bytes
/
Dish.java
File metadata and controls
29 lines (25 loc) · 836 Bytes
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
public class Dish {
String name;
double price;
Dish(String aName, double aPrice) {
name = aName;
price = aPrice;
}
// контроль корректного наименование блюда
public static boolean isCorrectName(String aStr) {
return !aStr.trim().isEmpty();
}
// контроль корректной цены
public static boolean isCorrectPrice(String aStr) {
try {
return Double.parseDouble(aStr) > 0;
} catch (NumberFormatException e) {
return false;
}
}
// вывод описания блюда
public void printDish() {
System.out.printf("%s, стоимость %s %s", name, Utils.toStringCustomFormat(price), Utils.getRoubleSuffix(price));
System.out.println();
}
}