diff --git a/src/main/java/millions/Share.java b/src/main/java/millions/Share.java index afb3947..5db6738 100644 --- a/src/main/java/millions/Share.java +++ b/src/main/java/millions/Share.java @@ -11,6 +11,16 @@ public Share(Stock stock, BigDecimal quantity, BigDecimal purchasePrice) { this.stock = stock; this.quantity = quantity; this.purchasePrice = purchasePrice; + + if (stock == null) { + throw new IllegalArgumentException("Stock cannot be null"); + } + if (quantity == null) { + throw new IllegalArgumentException("Quantity cannot be null"); + } + if (purchasePrice == null) { + throw new IllegalArgumentException("Purchase price cannot be null"); + } } public Share(Stock stock, int quantity, BigDecimal purchasePrice) {