forked from Yandex-Practicum/Java-Module-Project-YP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItem.java
More file actions
27 lines (23 loc) · 1019 Bytes
/
Item.java
File metadata and controls
27 lines (23 loc) · 1019 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
public class Item {
String nameOfItem;
double priceOfItem;
public String addAnItem() {
System.out.println("Введите название товара.");
nameOfItem = Main.sc.nextLine();
return nameOfItem;
}
public double addAnItemPrice() {
IsItANumber checkedString = new IsItANumber();
System.out.println("Введите стоимость товара в формате \"рубли.копейки\".");
while(true) {
String priceOfItem = Main.sc.nextLine();
if (!(checkedString.doubleNum(priceOfItem))) {
System.out.println("Ошибка: \"Введен недопустимый символ или отрицательное число!\" Повторите ввод стоимости товара в виде числа!");
}
else {
this.priceOfItem = Double.parseDouble(priceOfItem);
return this.priceOfItem;
}
}
}
}