Skip to content

Second sprint project work!!! - #1

Open
MihSolo wants to merge 5 commits into
mainfrom
dev
Open

MihSolo wants to merge 5 commits into
mainfrom
dev

Conversation

@MihSolo

@MihSolo MihSolo commented Oct 23, 2023

Copy link
Copy Markdown
Owner

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.

@nasibullin1412

Copy link
Copy Markdown

⚠️Приложение упало после ввода "Завершить"

image

@nasibullin1412

Copy link
Copy Markdown

🍏Скачет форматирование кода, старайся прожимать ctrl+alt+l перед тем, как делаешь коммит. https://devcolibri.com/%D0%B3%D0%BE%D1%80%D1%8F%D1%87%D0%B8%D0%B5-%D0%BA%D0%BB%D0%B0%D0%B2%D0%B8%D1%88%D0%B8-intellij-idea/

Comment thread src/main/java/Main.java Outdated
import java.util.Scanner;

public class Main {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍏Лишняя пустая строка

Comment thread src/main/java/PersonCount.java Outdated
Comment on lines +4 to +5


Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍏Лишние пустые строки

Comment thread src/main/java/PersonCount.java Outdated
Comment on lines +6 to +8
// private void requestToUser(){
// System.out.println("Hello! How many person will divided this bill?");
// }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍏Ненужный код лучше сразу удалять, а не оставлять комментарием

Comment thread 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();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️Упадёт при вводе всего кроме int

Comment thread src/main/java/PriceCalculator.java Outdated
private double finalSum;


PriceCalculator() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍏Настоятельно не рекомендую помещать логику в конструктор объекта, максимум что там должно быть - это инициализация полей. Остальную логику лучше вытащить в отдельный метод.

Comment thread src/main/java/PriceCalculator.java Outdated
product = userInput.next();
setProduct(product);
System.out.println("Please input product price.");
productPrice = userInput.nextDouble(); //нет проверки на строку.....тут появится ошибка при вводе другого типа.....программа прерывает работу....

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️Упадёт при вводе всего кроме double

Comment thread 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();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️Упадёт при вводе всего кроме double

Comment thread src/main/java/PriceCalculator.java Outdated
Comment on lines +61 to +63
int intValue = (int)Double.parseDouble(String.format("%.2f", personBill));//(int)personBill;
String convertToStr = Integer.toString(intValue);
switch(convertToStr.charAt(convertToStr.length() - 1)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍏Не самая удачная идея переводить в строку, когда можно округлить до целой части и применить операции % 10 или % 100 в зависимости от того, сколько последних цифр надо

@ghost

ghost commented Oct 26, 2023

Copy link
Copy Markdown

Привет! Всё исправил. Спасибо.

Comment on lines +69 to +86
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;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍏 Это всё можно переписать на

            switch (rubValue % 10) {
                case 1 -> System.out.println("рубль");
                case 2, 3, 4 -> System.out.println("рубля");
                default -> System.out.println("рублей");
            }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants