Skip to content

Request for check - #1

Open
VictorBlyakherov wants to merge 2 commits into
mainfrom
dev
Open

VictorBlyakherov wants to merge 2 commits into
mainfrom
dev

Conversation

@VictorBlyakherov

Copy link
Copy Markdown
Owner

No description provided.

return currentSum;
}

public boolean addItem(Item item) {

Copy link
Copy Markdown

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
Copy Markdown

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. Дело вкуса

Comment thread src/main/java/Item.java
@@ -0,0 +1,39 @@
public class Item {

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/Item.java
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
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants