Conversation
|
🍏Скачет форматирование кода, старайся прожимать |
src/main/java/Main.java
Outdated
| import java.util.Scanner; | ||
|
|
||
| public class Main { | ||
|
|
src/main/java/PersonCount.java
Outdated
|
|
||
|
|
src/main/java/PersonCount.java
Outdated
| // private void requestToUser(){ | ||
| // System.out.println("Hello! How many person will divided this bill?"); | ||
| // } |
There was a problem hiding this comment.
🍏Ненужный код лучше сразу удалять, а не оставлять комментарием
src/main/java/PersonCount.java
Outdated
| public int personCount(Scanner userInput) { | ||
| // requestToUser(); | ||
| System.out.println("Hello! How many person will divided this bill?"); | ||
| int userCount = userInput.nextInt(); |
There was a problem hiding this comment.
int
src/main/java/PriceCalculator.java
Outdated
| private double finalSum; | ||
|
|
||
|
|
||
| PriceCalculator() { |
There was a problem hiding this comment.
🍏Настоятельно не рекомендую помещать логику в конструктор объекта, максимум что там должно быть - это инициализация полей. Остальную логику лучше вытащить в отдельный метод.
src/main/java/PriceCalculator.java
Outdated
| product = userInput.next(); | ||
| setProduct(product); | ||
| System.out.println("Please input product price."); | ||
| productPrice = userInput.nextDouble(); //нет проверки на строку.....тут появится ошибка при вводе другого типа.....программа прерывает работу.... |
There was a problem hiding this comment.
double
src/main/java/PriceCalculator.java
Outdated
| productPrice = userInput.nextDouble(); //нет проверки на строку.....тут появится ошибка при вводе другого типа.....программа прерывает работу.... | ||
| while(productPrice < 0) { | ||
| System.out.println("That is not correct price value. Try again please:"); | ||
| productPrice = userInput.nextDouble(); |
There was a problem hiding this comment.
double
src/main/java/PriceCalculator.java
Outdated
| int intValue = (int)Double.parseDouble(String.format("%.2f", personBill));//(int)personBill; | ||
| String convertToStr = Integer.toString(intValue); | ||
| switch(convertToStr.charAt(convertToStr.length() - 1)) { |
There was a problem hiding this comment.
🍏Не самая удачная идея переводить в строку, когда можно округлить до целой части и применить операции % 10 или % 100 в зависимости от того, сколько последних цифр надо
|
Привет! Всё исправил. Спасибо. |
| switch (rubValue % 10) { | ||
| case 1: | ||
| System.out.println("рубль"); | ||
| break; | ||
| case 2: | ||
| case 3: | ||
| case 4: | ||
| System.out.println("рубля"); | ||
| break; | ||
| case 5: | ||
| case 6: | ||
| case 7: | ||
| case 8: | ||
| case 9: | ||
| case 0: | ||
| System.out.println("рублей"); | ||
| break; | ||
| } |
There was a problem hiding this comment.
🍏 Это всё можно переписать на
switch (rubValue % 10) {
case 1 -> System.out.println("рубль");
case 2, 3, 4 -> System.out.println("рубля");
default -> System.out.println("рублей");
}

Main class -> Declared all classes and methods which created. Classes which from Java, necessary for programm function.
PersonCount class -> with this class identifies how many people, will divided bill.
PriceCalculator -> class and methods realization, which needed for price determination. Have method, for checking correct currency name description , depend from currency amount.