Skip to content

Commit

Permalink
Fix price retrieval in commit method
Browse files Browse the repository at this point in the history
  • Loading branch information
Solveig Natvig committed Mar 22, 2026
1 parent ba7303a commit 33cebc4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/Purchase.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ public Purchase(Share share, int week) {

@Override
public void commit(Player player) {
BigDecimal price = this.getShare().getPurchasePrice();
BigDecimal price = this.getCalculator().calculateTotal();

if (isCommitted() || (player.getMoney().compareTo(price) < 0)) {
return;
}

player.withdrawMoney(price);
player.getPortfolio().addShare(getShare());
player.getPortfolio().addShare(this.getShare());
player.getTransactionArchive().add(this);

this.committed = true;
Expand Down

0 comments on commit 33cebc4

Please sign in to comment.