forked from Yandex-Practicum/Java-Module-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCounter.java
More file actions
31 lines (26 loc) · 1008 Bytes
/
Counter.java
File metadata and controls
31 lines (26 loc) · 1008 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
30
31
import java.util.Scanner;
public class Counter {
int personCount;
Order order = new Order();
Counter(int aPersonCount) {
personCount = aPersonCount;
}
// контроль количества посетителей x
static boolean checkPersonCount(int aInt) {
return aInt > 1;
}
// получить допустимое количество гостей
public static int getPersonCount() {
Scanner scanner = new Scanner(System.in);
String sPersonCount;
System.out.println("На сколько человек необходимо разделить счёт?");
while (true) {
sPersonCount = scanner.next();
if (!Utils.isInt(sPersonCount) || !checkPersonCount(Integer.parseInt(sPersonCount))) {
System.out.println("Введите целое число больше 1");
} else {
return Integer.parseInt(sPersonCount);
}
}
}
}