Skip to content

Pull request - #1

Open
Bugrov1 wants to merge 5 commits into
mainfrom
dev
Open

Bugrov1 wants to merge 5 commits into
mainfrom
dev

Conversation

@Bugrov1

@Bugrov1 Bugrov1 commented Feb 12, 2023

Copy link
Copy Markdown
Owner

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

Comment thread src/main/java/Main.java
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 "рублей";
}

Copy link
Copy Markdown

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 включительно находится.

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

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/Main.java
Comment on lines +72 to +77






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/Main.java
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){

Copy link
Copy Markdown

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 thread src/main/java/Main.java
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 "рублей";
}

Copy link
Copy Markdown

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

@Bugrov1 Bugrov1 Feb 15, 2023 •

Copy link
Copy Markdown
Owner Author

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