Skip to content

Commit

Permalink
Added StockTradingGameApp.java class
Browse files Browse the repository at this point in the history
  • Loading branch information
elisab3 committed Apr 23, 2026
1 parent 6d01998 commit c567e2a
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/main/java/View/StockTradingGameApp.java
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);
}
}

0 comments on commit c567e2a

Please sign in to comment.