-
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.
Feat: Added stats page to in game view
- Loading branch information
Showing
6 changed files
with
93 additions
and
31 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
12 changes: 10 additions & 2 deletions
12
...ava/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/financialsummary/SummaryController.java
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,23 +1,31 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.financialsummary; | ||
|
|
||
| import edu.ntnu.idi.idatt2003.g40.mappe.engine.Exchange; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.service.event.EventManager; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewController; | ||
|
|
||
| public class SummaryController extends ViewController<SummaryView> { | ||
|
|
||
| private Exchange exchange; | ||
| /** | ||
| * {@inheritDoc}. | ||
| */ | ||
| public SummaryController(final SummaryView viewElement, | ||
| final EventManager eventManager) | ||
| final EventManager eventManager, | ||
| final Exchange exchange) | ||
| throws IllegalArgumentException { | ||
| this.exchange = exchange; | ||
| super(viewElement, eventManager); | ||
| } | ||
|
|
||
| @Override | ||
| protected void initInteractions() { | ||
| getViewElement().setOnAction(SummaryActions.NEXT_WEEK, () -> { | ||
| System.out.println("Next week!"); | ||
| exchange.nextWeek(); | ||
| }); | ||
|
|
||
| exchange.weekProperty().addListener((observable, o, n) -> { | ||
| getViewElement().setWeek((Integer) n); | ||
| }); | ||
| } | ||
| } |
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
44 changes: 43 additions & 1 deletion
44
src/main/java/edu/ntnu/idi/idatt2003/g40/mappe/view/widgets/stats/StatsController.java
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,4 +1,46 @@ | ||
| package edu.ntnu.idi.idatt2003.g40.mappe.view.widgets.stats; | ||
|
|
||
| public class StatsController { | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.engine.Exchange; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.model.Player; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.model.Share; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.model.Transaction; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.service.PurchaseCalculator; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.service.TransactionCalculator; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.service.TransactionFactory; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.service.TransactionType; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.service.event.EventManager; | ||
| import edu.ntnu.idi.idatt2003.g40.mappe.view.ViewController; | ||
|
|
||
| import java.math.BigDecimal; | ||
|
|
||
| public class StatsController extends ViewController<StatsView> { | ||
|
|
||
| private Player player; | ||
| private Exchange exchange; | ||
|
|
||
| /** | ||
| * {@inheritDoc} | ||
| */ | ||
| public StatsController(final StatsView viewElement, | ||
| final EventManager eventManager, | ||
| final Player player, | ||
| final Exchange exchange) | ||
| throws IllegalArgumentException { | ||
| this.player = player; | ||
| this.exchange = exchange; | ||
| super(viewElement, eventManager); | ||
| } | ||
|
|
||
| @Override | ||
| protected void initInteractions() { | ||
| getViewElement().setOnAction(StatsActions.BUY_SHARES, () -> { | ||
| BigDecimal amountToBuy = new BigDecimal("1.0"); | ||
| Transaction transaction = exchange.buy( | ||
| getViewElement().getCurrentStock().getSymbol(), | ||
| amountToBuy, | ||
| player | ||
| ); | ||
|
|
||
| }); | ||
| } | ||
| } |
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
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