Skip to content
Snippets Groups Projects

Ukol2/poliak

Closed Petr Poliak requested to merge poliape2/eShop:ukol2/poliak into master
4 files
+ 87
11
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -19,7 +19,7 @@ public class DiscountedItem extends Item {
public DiscountedItem(int id, String name, float price, String category, int discount, Date discountFrom, Date discountTo) {
super(id, name, price, category);
this.discount = discount > 100 ? 0 : discount;
this.discountTo = discountFrom;
this.discountFrom = discountFrom;
this.discountTo = discountTo;
}
@@ -51,11 +51,12 @@ public class DiscountedItem extends Item {
@Override
public boolean equals(Object object) {
if(object instanceof DiscountedItem){
if (object instanceof DiscountedItem) {
DiscountedItem zbozi = (DiscountedItem) object;
return (super.equals(zbozi)
&& discount == zbozi.getDiscount()
&& discountTo.equals(zbozi.getDiscountTo()));
&& discount == zbozi.getDiscount()
&& discountTo.equals(zbozi.getDiscountTo())
&& discountFrom.equals(zbozi.getDiscountFrom()));
}
return false;
}
@@ -124,6 +125,6 @@ public class DiscountedItem extends Item {
public DiscountedItem copy() {
return new DiscountedItem(getID(), getName(), getPrice(), getCategory(), discount, discountFrom, discountTo);
return new DiscountedItem(getID(), getName(), getOriginalPrice(), getCategory(), discount, discountFrom, discountTo);
}
}