Skip to content

Commit

Permalink
dette bør fikse problemet
Browse files Browse the repository at this point in the history
  • Loading branch information
EspenTinius committed Mar 13, 2026
1 parent 6931e12 commit 3003934
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/Exchange.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ public Transaction buy(String symbol, BigDecimal quantity, Player player) {
Stock stock = stockMap.get(symbol);
Share share = new Share(stock, quantity, stock.getSalesPrice());
TransactionCalculator calculator = new PurchaseCalculator(share);
return new Purchase(share, week, calculator, player);
player.withdrawMoney(calculator.calculateTotal());
return new Purchase(share, week, calculator);
}

public Transaction sell(Share share, Player player) {
TransactionCalculator calculator = new SaleCalculator(share);
return new Sale(share, week, calculator, player);
player.addMoney(calculator.calculateTotal());
return new Sale(share, week, calculator);
}

public void advance() {
Expand Down

0 comments on commit 3003934

Please sign in to comment.