diff --git a/src/main/java/millions/Stock.java b/src/main/java/millions/Stock.java index 41a3ead..632c4b7 100644 --- a/src/main/java/millions/Stock.java +++ b/src/main/java/millions/Stock.java @@ -13,12 +13,18 @@ public Stock(String symbol, String company, List prices) { this.symbol = symbol; this.company = company; this.prices = new ArrayList<>(prices); + + if (symbol == null || symbol.isBlank()) { + throw new IllegalArgumentException("Symbol cannot be null or blank"); + } + + if (company == null || company.isBlank()) { + throw new IllegalArgumentException("Company cannot be null or blank"); + } } public Stock(String symbol, String company, BigDecimal initialPrice) { - this.symbol = symbol; - this.company = company; - this.prices = new ArrayList<>(List.of(initialPrice)); + this(symbol, company, new ArrayList<>(List.of(initialPrice))); } public String getSymbol() {