Skip to content

Консольное приложение - исправления - #2

Open
pakhomn wants to merge 4 commits into
mainfrom
newdev
Open

pakhomn wants to merge 4 commits into
mainfrom
newdev

Conversation

@pakhomn

@pakhomn pakhomn commented Jul 2, 2023

Copy link
Copy Markdown
Owner

Исправления

Comment thread src/main/java/Rubl.java
this.sumDouble = sumDouble;
}

public static void rublCorrect(String sumStr, Double sumDouble, String rubSogl) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Аргумент rubSogl передается, но не используется. Стоит убрать

Comment thread src/main/java/Rubl.java
System.out.println(sumStr + " " + rubSogl);
} else if (sumDouble > 10) {
//System.out.println("больше 10");
if (sumStr.substring(sumStr.length() - 5, sumStr.length() - 4).equals("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.

Можно все это условие заменить на sumStr.charAt(sumStr.length() - 5) == '1'. Студия подсказывает эту оптимизацию

Comment thread src/main/java/Rubl.java
System.out.println(sumStr + " " + rubSogl);
return;
}
switch (sumStr.substring(sumStr.length() - 4, sumStr.length() - 3)) {

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/Rubl.java
default:
rubSogl = "рублей";
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.

Здесь и выше условия один в один повторяются. Их можно объединить. Вынести в общий метод, например.

Comment thread src/main/java/Main.java

String end = "завершить";
String text = "";
Double pr = 0.0;

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/Main.java
}


System.out.println("\n*****************\nСписок всех товаров:" + list.substring(0, list.length()) + "\n\nОбщая сумма: " + sum + " Количество человек: " + k + "\n");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

list.substring(0, list.length()) - это и есть весь list.

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