Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Проектная работа No1#1

Open
marugish wants to merge 3 commits intomain from
dev
Open

Проектная работа No1 #1
marugish wants to merge 3 commits intomain from
dev

Conversation

@marugish
Copy link
Owner

@marugish marugish commented Jan 9, 2024

Первая сдача. Просьба принять на проверку. Описание представлено в readme.
Спасибо!

@@ -0,0 +1,31 @@
public class Calculator {
int users;
Copy link

@i-masloed i-masloed Jan 9, 2024

Choose a reason for hiding this comment

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

Рекомендация: Форматирование кода - в Java принят немного другой стиль форматирования кода. Если не вдаваться в детали, то легко и быстро отформатировать код в Android Studio можно следующей комбинацией клавиш: в Windows Ctrl + Alt + L , в MacOs ⌘ + ⌥ + L.

}
case 2, 3, 4 ->
{
if (cost % 100 == 12 || cost % 100 == 13 || cost % 100 == 14)
Copy link

@i-masloed i-masloed Jan 9, 2024

Choose a reason for hiding this comment

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

Рекомендация: cost % 100 считается несколько раз, имеет смысл вынести в переменную, также имеет смысл оптимизировать условие: cost % 10>= 12 && cost % 10<= 14

int cost = (int) Math.floor(totalCostForEach);
switch (cost % 10) {
case 1 -> {
if (cost % 100 == 11) currency = " рублей.";
Copy link

@i-masloed i-masloed Jan 9, 2024

Choose a reason for hiding this comment

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

Рекомендация: поыторяющиеся строки имеет смысл вынести в константы

// Вывод результатов пользователю
calculator.displayProducts();
System.out.println("Итоговая стоимость: "
+ formatter.roundingTheDouble(calculator.calculateScoreForEachPerson())
Copy link

@i-masloed i-masloed Jan 9, 2024

Choose a reason for hiding this comment

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

Рекомендация: calculator.calculateScoreForEachPerson() рассчитывается несколько раз, имеет смысл вынести это значение в переменную

Copy link
Owner Author

Добрый день! Это вторая сдача работы. Просьба проверить.
0) Исправила ошибку в обработке названия товара

  1. Отформатировала код с помощью комбинации Ctrl+Alt+L , согласно правилам Java
  2. Вынесла cost % 100 в отдельную переменную, оптимизировала условие
    3 и 4) повторяющиеся строки и выражения вынесла в отдельные переменные
    Спасибо!

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

Reviewers

1 more reviewer

@i-masloed i-masloed i-masloed left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /