-
Notifications
You must be signed in to change notification settings - Fork 222
КОНСОЛЬНОЕ ПРИЛОЖЕНИЕ 1 #75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| System.out.println("Некорректное значение для подсчёта."); | ||
| } | ||
| add.getNumberOfPpl(numberOfPeople);//добавляем кол-во людей | ||
| } while (numberOfPeople < 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Имеет смысл выделить такие логические части программы (обработка ввода количества людей, ввод товаров) в отдельные методы, чтобы было проще их воспринимать, и здесь их последовательно вызывать
| add.count(); | ||
| add.nameOfCurrency(); | ||
| } | ||
| private static void typeGoods() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Для простого вывода строки можно не создавать отдельный метод
| @@ -0,0 +1,58 @@ | |||
| public class Calculator { | |||
|
|
|||
| private Product[] array = new Product[20]; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше использовать список из коллекций - например, ArrayList, потому что размер массива ограничен, а теоретически количество товаров неограниченное
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Мой эррей же расширяется
| System.out.println("\nСумма для каждого составляет: " + sumForEach + " рубля."); | ||
| } else if (rounded == 0) | ||
| System.out.println("\nСумма для каждого составляет: " + sumForEach + " рублей."); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Есть принцип, который называется DRY - Don't repeat yourself. По этому правилу, если видишь, что есть многократно повторяющиеся участки кода, то их можно объединить. Здесь, например, изменяется лишь окончание, поэтому можно сделать строку, которая будет изменяться в зависимости от rounded, и затем присоединять её к предложению
|
Простите я сильно болел гриппом, вот поправился, внес правки. |
No description provided.