Skip to content

Проект - #1

Open
Shahidow wants to merge 2 commits into
mainfrom
dev
Open

Shahidow wants to merge 2 commits into
mainfrom
dev

Conversation

@Shahidow

@Shahidow Shahidow commented Jun 4, 2023

Copy link
Copy Markdown
Owner

No description provided.

Comment thread src/main/java/Main.java Outdated
return price;
}

public String declension(double sum) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⏫ Так как методы declension и price используются только в классе Calculator, их можно сделать private.

Comment thread src/main/java/Main.java Outdated
public String declension(double sum) {
sum = Math.floor(sum);
for(int i=11; i<=14; i++) {
if((sum-i)%100 == 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Очень интересный алгоритм определения правильного окончания.

⚠ ️Немного сбивает с толку то, что все проверки находятся
внутри цикла. К сожалению, такой алгоритм не покрывает сценарий, когда sum равна 12, 13 или 14. В этих случаях мы всегда
будем получать "рубля".

Советую оставить в цилке только первую проверку

for(int i=11;i<=14;i++){
        if((sum-i)%100==0){
            return" рублей.";
        }
}

А следом проверять остальные условия.

Comment thread src/main/java/Main.java
}
} No newline at end of file
}
class Calculator{

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