Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

Request for check#1

Open
VictorBlyakherov wants to merge 2 commits intomain from
dev
Open

Request for check #1
VictorBlyakherov wants to merge 2 commits intomain from
dev

Conversation

@VictorBlyakherov
Copy link
Owner

@VictorBlyakherov VictorBlyakherov commented Mar 10, 2023

No description provided.

return currentSum;
}

public boolean addItem(Item item) {
Copy link

@ilshat-abdulin ilshat-abdulin Mar 10, 2023

Choose a reason for hiding this comment

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

🍏 Можно вместо boolean добавить void и убрать return, т.к. возвращаемое значение у тебя нигде не используется

Comment on lines +13 to +19
if (lastDigit == 1) {
rublesValue = "рубль";
} else if (lastDigit >= 2 && lastDigit <= 4) {
rublesValue = "рубля";
} else {
rublesValue = "рублей";
}
Copy link

@ilshat-abdulin ilshat-abdulin Mar 10, 2023

Choose a reason for hiding this comment

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

🍏 Такого рода блоки, как if-then-else, в Java можно заменить на switch case. Дело вкуса

@@ -0,0 +1,39 @@
public class Item {
Copy link

@ilshat-abdulin ilshat-abdulin Mar 10, 2023

Choose a reason for hiding this comment

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

Круто, что используешь класс, как модель данных для описания товара 👍

Comment on lines +18 to +37
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

Item item = (Item) o;

if (Double.compare(item.price, price) != 0) return false;
return name != null ? name.equals(item.name) : item.name == null;
}

@Override
public int hashCode() {
int result;
long temp;
result = name != null ? name.hashCode() : 0;
temp = Double.doubleToLongBits(price);
result = 31 * result + (int) (temp ^ (temp >>> 32));
return result;
}
Copy link

@ilshat-abdulin ilshat-abdulin Mar 10, 2023

Choose a reason for hiding this comment

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

Весьма полезное решение переопределять hashCode и equals 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@ilshat-abdulin ilshat-abdulin ilshat-abdulin left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /