Skip to content

Commit 5d22bb1

Browse files
committed
Finished product tests
1 parent 3025e99 commit 5d22bb1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package pl.edu.agh.mwo.invoice;
22

33
public class Demo {
4+
public static final String SDLKFJSDKJFLKSDJFLK = "";
5+
46
public static void main(String[] args) {
5-
System.out.println(0.1 + 0.2);
7+
// System.out.println(0.1 + 0.2);
8+
System.out.println(" ".trim().isEmpty());
69
}
710
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package pl.edu.agh.mwo.invoice.product;
22

3+
import java.io.IOException;
34
import java.math.BigDecimal;
45

56
public abstract class Product {
@@ -10,6 +11,12 @@ public abstract class Product {
1011
private final BigDecimal taxPercent;
1112

1213
protected Product(String name, BigDecimal price, BigDecimal tax) {
14+
if (name == null || name.equals("")) {
15+
throw new IllegalArgumentException("Product name cannot be null.");
16+
}
17+
if (price == null || price.compareTo(BigDecimal.ZERO) == -1) {
18+
throw new IllegalArgumentException("Price of the product cannot be null or negative.");
19+
}
1320
this.name = name;
1421
this.price = price;
1522
this.taxPercent = tax;

0 commit comments

Comments
 (0)