Skip to content

Commit 29fa499

Browse files
committed
Full ProductTest working
1 parent 9434002 commit 29fa499

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main/java/pl/edu/agh/mwo/invoice/product/Product.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ public abstract class Product {
1010
private final BigDecimal taxPercent;
1111

1212
protected Product(String name, BigDecimal price, BigDecimal tax) {
13+
if (name == null || name.isEmpty()) {
14+
throw new IllegalArgumentException("Product name cannot be null or empty.");
15+
}
16+
if (price == null || price.signum() == -1) {
17+
throw new IllegalArgumentException("Price name cannot be null.");
18+
}
1319
this.name = name;
1420
this.price = price;
1521
this.taxPercent = tax;

0 commit comments

Comments
 (0)