Skip to content

Conversation

@Bugrov1
Copy link
Owner

@Bugrov1 Bugrov1 commented Feb 12, 2023

Тестовое Задание на курсе Яндекс.Практикум.

Comment on lines 109 to 122
double numRound = Math.floor(number);
double leftOver= Math.floor(numRound)%10;
if(leftOver==1){
return "рубль";
}
else if (leftOver>=2&&leftOver<=4){
return "рубля";
}
else if (leftOver>=5&&leftOver<=9){
return "рублей";
}else{
return "рублей";
}

Choose a reason for hiding this comment

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

⚠ Обрати внимание, что если значение будет равным 114, то на выходе получится 114 рубля. То есть, в таком случае, нужно учитывать диапазон чисел 11-19 - "рублей" - для этого стоит проверять, что (114 % 100) между 11 и 19 включительно находится.

static void check(){
System.out.println("Добавленные товары: "+goodsList);
System.out.println("ОБщая сумма: "+priceTotal+" "+Convert.ending(priceTotal));
if (priceTotal ==0&&goodsList.equals("")){System.out.println("Вы не выбрали товар");}//1111

Choose a reason for hiding this comment

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

А вот это полезное сообщение. Не все об этом заботятся) 👍

Comment on lines +72 to +77






Choose a reason for hiding this comment

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

🍏 Лучше не оставлять пустые строки, лишние комментарии для компактности

Comment on lines +109 to +111
double numRound = Math.floor(number);
double leftOver= Math.floor(numRound)%10;
if(Math.floor(numRound)%100>=11&&Math.floor(numRound)%100<=19){

Choose a reason for hiding this comment

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

🍏 Можно же один раз округлить (и в идеале привести к целочисленному типу) int numRound = (int) Math.floor(number)

Затем уже использовать в проверках
if(numRound %100>=11&&numRound %100<=19)

Comment on lines +113 to +125
}
else{
if(leftOver==1){
return "рубль";
}
else if (leftOver>=2&&leftOver<=4){
return "рубля";
}
else if (leftOver>=5&&leftOver<=9){
return "рублей";
}else{
return "рублей";
}

Choose a reason for hiding this comment

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

🍏 Можно использовать автоформатирование, чтобы должным образом выровнять отступы
Комбинации клавиш:
Windows: Ctrl + Alt + L
Linux: Ctrl + Shift + Alt + L
macOS: Option + Command + L

Copy link
Owner Author

@Bugrov1 Bugrov1 Feb 15, 2023

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.

3 participants