Repository navigation
Conversation
Comment on lines
+5
to
+10
| int peopleCount; | ||
| String productName; | ||
| double productPrice; | ||
| Product product; | ||
| double result; | ||
| String answer; |
There was a problem hiding this comment.
Переменные нужно объявлять как можно ближе к месту их использования
Comment on lines
+69
to
+70
| double total = 0; | ||
| String products = ""; |
There was a problem hiding this comment.
Эти поля можно приватными сделать, раз у тебя есть к ним get методы
Comment on lines
+78
to
+80
| void calculateTotal(double productPrice) { | ||
| this.total = this.total + productPrice; | ||
| } |
There was a problem hiding this comment.
Это можно не выносить в отдельную функцию
Comment on lines
+92
to
+93
| String name; | ||
| double price; |
There was a problem hiding this comment.
поля можно сделать неизменяемыми:
Suggested change
| String name; | |
| double price; | |
| final String name; | |
| final double price; |
| } while (!answer.equalsIgnoreCase("завершить")); | ||
| System.out.println("Добавленные товары:" + calculator.getProducts()); | ||
| result = calculator.getTotal() / peopleCount; | ||
| System.out.println("Каждый человк должен заплатить: " + Formatter.getFormatPrice(result) + Formatter.getEnding(result)); |
There was a problem hiding this comment.
Опечатка
Suggested change
| System.out.println("Каждый человк должен заплатить: " + Formatter.getFormatPrice(result) + Formatter.getEnding(result)); | |
| System.out.println("Каждый человек должен заплатить: " + Formatter.getFormatPrice(result) + Formatter.getEnding(result)); |
Comment on lines
+108
to
+114
| if (result == 1) { | ||
| return " рубль"; | ||
| } else if (result > 2 && result < 5) { | ||
| return " рубля"; | ||
| } else { | ||
| return " рублей"; | ||
| } |
There was a problem hiding this comment.
Чтобы функция была более универсальной, можно не добавлять к возвращаемой строке пробел, а делать это в точке вызова функции:
Suggested change
| if (result == 1) { | |
| return " рубль"; | |
| } else if (result > 2 && result < 5) { | |
| return " рубля"; | |
| } else { | |
| return " рублей"; | |
| } | |
| if (result == 1) { | |
| return "рубль"; | |
| } else if (result > 2 && result < 5) { | |
| return "рубля"; | |
| } else { | |
| return "рублей"; | |
| } |
Owner
Author
|
Поправил ошибки во втором коммите |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Проектная работа №1
Пишем консольное приложение №1