-
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.
Added StockTradingGameApp.java class
- Loading branch information
Showing
1 changed file
with
49 additions
and
0 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 |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package View; | ||
|
|
||
| import javafx.application.Application; | ||
| import javafx.stage.Stage; | ||
| import Controller.StockFileHandler; | ||
| import Model.*; | ||
|
|
||
| import java.math.BigDecimal; | ||
|
|
||
| public class StockTradingGameApp extends Application { | ||
| private Stage primaryStage; | ||
| private Exchange exchange; | ||
| private Player player; | ||
| private StockFileHandler fileHandler; | ||
|
|
||
| @Override | ||
| public void start(Stage primaryStage) { | ||
| this.primaryStage = primaryStage; | ||
| this.fileHandler = new StockFileHandler(); | ||
|
|
||
| primaryStage.setTitle("Stock Trading Game"); | ||
| primaryStage.setWidth(1200); | ||
| primaryStage.setHeight(800); | ||
|
|
||
| showGameSetup(); | ||
| primaryStage.show(); | ||
| } | ||
|
|
||
| private void showGameSetup() { | ||
| GameSetupScene setupScene = new GameSetupScene(this::startGame); | ||
| primaryStage.setScene(setupScene.getScene()); | ||
| } | ||
|
|
||
| private void startGame(GameSetupScene.StartGameData gameData) { | ||
| this.exchange = gameData.exchange; | ||
| this.player = new Player(gameData.playerName, gameData.startingCapital); | ||
|
|
||
| MainGameScene gameScene = new MainGameScene(exchange, player, this::endGame); | ||
| primaryStage.setScene(gameScene.getScene()); | ||
| } | ||
|
|
||
| private void endGame() { | ||
| primaryStage.close(); | ||
| } | ||
|
|
||
| public static void main(String[] args) { | ||
| launch(args); | ||
| } | ||
| } |