-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
martin
committed
Mar 5, 2026
1 parent
9964e4b
commit 74507e4
Showing
1 changed file
with
17 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,25 @@ | ||
| package temppackage; | ||
|
|
||
| import temppackage.calculators.SaleCalculator; | ||
|
|
||
| public class Sale extends Transaction { | ||
| public Sale(Share share, int week) {} | ||
|
|
||
| public Sale(Share share, int week) { | ||
| super(share, week, new SaleCalculator(share)); | ||
| } | ||
|
|
||
| @Override | ||
| public void commit(Player player) { | ||
| // TODO Auto-generated method stub | ||
| super.commit(player); | ||
| if (isCommitted()) { | ||
| throw new IllegalStateException("Already committed"); | ||
| } | ||
|
|
||
| if (!player.getPortfolio().contains(getShare())) { | ||
| throw new IllegalStateException("Does not own the share"); | ||
| } | ||
| player.addMoney(getCalculator().calculateTotal()); | ||
| player.getPortfolio().removeShare(getShare()); | ||
| player.getTransactionArchive().add(this); | ||
| setCommitted(true); | ||
| } | ||
| } |