mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-19 21:04:36 +02:00
Add classes Consumable and Rentable to package catering.catalog
This commit is contained in:
parent
4dce95d86d
commit
090ae6d439
47
src/main/java/catering/catalog/Consumable.java
Normal file
47
src/main/java/catering/catalog/Consumable.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
package catering.catalog;
|
||||
|
||||
import javax.money.MonetaryAmount;
|
||||
import com.mysema.commons.lang.Assert;
|
||||
import jakarta.persistence.Entity;
|
||||
import org.salespointframework.catalog.Product;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
@Entity
|
||||
class Consumable extends Product {
|
||||
private MonetaryAmount wholesalePrice;
|
||||
private MonetaryAmount promotionPrice;
|
||||
public Consumable(String name, MonetaryAmount price, Iterable<String> categories) {
|
||||
super(name,price);
|
||||
Assert.notNull(price, "Price must not be null!");
|
||||
// for (String category : categories) {
|
||||
// this.addCategory(category);
|
||||
// }
|
||||
categories.forEach(this::addCategory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull MonetaryAmount getPrice() {
|
||||
MonetaryAmount normal_price = super.getPrice();
|
||||
return normal_price.isGreaterThan(promotionPrice) ? promotionPrice : normal_price;
|
||||
}
|
||||
@NonNull MonetaryAmount getRetailPrice() {
|
||||
return super.getPrice();
|
||||
}
|
||||
@NonNull MonetaryAmount getPromotionPrice() {
|
||||
return promotionPrice;
|
||||
}
|
||||
@NonNull MonetaryAmount getWholesalePrice() {
|
||||
return wholesalePrice;
|
||||
}
|
||||
|
||||
public void setPromotionPrice(MonetaryAmount price) {
|
||||
Assert.notNull(price, "promotionPrice must not be null!");
|
||||
promotionPrice = price;
|
||||
}
|
||||
public void setWholesalePrice(MonetaryAmount price) {
|
||||
Assert.notNull(price, "wholesalePrice must not be null!");
|
||||
wholesalePrice = price;
|
||||
}
|
||||
|
||||
|
||||
}
|
21
src/main/java/catering/catalog/Rentable.java
Normal file
21
src/main/java/catering/catalog/Rentable.java
Normal file
|
@ -0,0 +1,21 @@
|
|||
package catering.catalog;
|
||||
|
||||
import com.mysema.commons.lang.Assert;
|
||||
import jakarta.persistence.Entity;
|
||||
import org.salespointframework.catalog.Product;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
import javax.money.MonetaryAmount;
|
||||
|
||||
@Entity
|
||||
class Rentable extends Product {
|
||||
public Rentable(String name, javax.money.MonetaryAmount price, Iterable<String> categories) {
|
||||
super(name,price);
|
||||
Assert.notNull(price, "Price must not be null!");
|
||||
// for (String category : categories) {
|
||||
// this.addCategory(category);
|
||||
// }
|
||||
categories.forEach(this::addCategory);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue