diff --git a/src/main/java/millions/Stock.java b/src/main/java/millions/Stock.java index 886ecba..c40f9ff 100644 --- a/src/main/java/millions/Stock.java +++ b/src/main/java/millions/Stock.java @@ -29,4 +29,35 @@ public BigDecimal getSalesPrice() { public void addNewSalesPrice(BigDecimal price) { this.prices.add(price); } + + public List getHistoricalPrices() { + return this.prices; + } + + public BigDecimal getHighestPrice() { + BigDecimal highestPrice = this.prices.get(0); + for (BigDecimal price : this.prices) { + if (price.compareTo(highestPrice) > 0) { + highestPrice = price; + } + } + return highestPrice; + } + + public BigDecimal getLowestPrice() { + BigDecimal lowestPrice = this.prices.get(0); + for (BigDecimal price : this.prices) { + if (price.compareTo(lowestPrice) < 0) { + lowestPrice = price; + } + } + return lowestPrice; + } + + public BigDecimal getLatestPriceChange() { + BigDecimal currentPrice = this.prices.getLast(); + BigDecimal lastPrice = this.prices.get(this.prices.size() - 2); + + return currentPrice.subtract(lastPrice); + } }