Skip to content

Commit

Permalink
refactor: Model classes based on test results.
Browse files Browse the repository at this point in the history
  • Loading branch information
PawelSapula committed May 25, 2026
1 parent 50a7131 commit 5c86b15
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/main/java/edu/ntnu/idi/idatt/model/market/Newspaper.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

import edu.ntnu.idi.idatt.model.enums.NewspaperEnum;

//TODO: junit

/**
* Newspaper class
*
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/edu/ntnu/idi/idatt/model/market/Stock.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ public BigDecimal getLatestPriceChangePercent() {
return BigDecimal.ZERO;
}

return (getLatestPriceChange().divide(prices.get(prices.size() - 2), 2, RoundingMode.HALF_UP))
.multiply(new BigDecimal("100"));
return (getLatestPriceChange().multiply(new BigDecimal("100"))
.divide(prices.get(prices.size() - 2), 2, RoundingMode.HALF_UP));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ public BigDecimal getChangeFromStock() {
BigDecimal costTotal = getShares().stream().map(s -> s.getTotalPurchasePrice())
.reduce(BigDecimal.ZERO, BigDecimal::add);

if (costTotal.compareTo(BigDecimal.ZERO) <= 0)
return BigDecimal.ZERO;

return profitTotal.divide(costTotal, 2, RoundingMode.HALF_UP).multiply(BigDecimal.valueOf(100));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public StockComponent(Stock stock) {
CssUtils.apply(title, CssUtils.BIG_TEXT_32);
labels.forEach(l -> CssUtils.apply(l, CssUtils.MED_TEXT_16));

String color = CssUtils.generateValueColors(stock.getLatestPriceChange().doubleValue());
String color = CssUtils.generateValueColors(stock.getLatestPriceChange());
CssUtils.apply(changeValue, color);
CssUtils.apply(changeValuePercent, color);

Expand Down

0 comments on commit 5c86b15

Please sign in to comment.