Skip to content

Task1 - #1

Open
yakoeka wants to merge 3 commits into
devfrom
task1
Open

yakoeka wants to merge 3 commits into
devfrom
task1

Conversation

@yakoeka

@yakoeka yakoeka commented Dec 17, 2023

Copy link
Copy Markdown
Owner

No description provided.

this.guests = guests;
}

static int getAmountOfGuests(Scanner scanner) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

старайся использовать нестатические функции, так так статические функции постоянно висят в памяти и соответственно занимают её, чего стоит избегать, иначе на устройстве может банально закончится память и твоё приложение закроется с ошибкой

}

static int getAmountOfGuests(Scanner scanner) {
int guests;

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/Calculator.java Outdated
static void printResultingSum(Calculator calculator) {
double resultSum = calculator.sum / calculator.guests;
int resultSumIntDiv10 = ((int) resultSum) % 10;
if (resultSumIntDiv10 == 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.

попробуй переделать на оператор switch-case, для ситуаций, когда более 2 условий он подходит гораздо лучше и код становится более понятным

Comment thread src/main/java/Calculator.java Outdated
double resultSum = calculator.sum / calculator.guests;
int resultSumIntDiv10 = ((int) resultSum) % 10;
if (resultSumIntDiv10 == 1) {
System.out.println(String.format("%.2f рубль", resultSum));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

у тебя повторяется один и тот же кусок кода с выводом строки, попробуй сделать функцию, которая будет возвращать правильно склоненное слово "рубль"

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