Skip to content

Commit

Permalink
Merge pull request #55 from IDATT2003-gruppe06/dev
Browse files Browse the repository at this point in the history
Merge into main
  • Loading branch information
nolydvo authored May 26, 2026
2 parents e2450da + d433511 commit 810c2fd
Show file tree
Hide file tree
Showing 67 changed files with 3,562 additions and 279 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ build/

### Mac OS ###
.DS_Store

shell.nix
6 changes: 0 additions & 6 deletions .vscode/settings.json

This file was deleted.

11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Millions stock trading game

Made by:
- Nikolai Oliver Aasheim Lydvo
- Martin Olai Amundsen Henøen

How to run the game:
1. Download the latest release
2. Ensure you have Java 25 and the Maven commandline tool installed
3. Navigate to the project root directory and run the command: "mvn javafx:run"
4. Set up your game configuration and start game
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>6.0.1</version>
<version>5.11.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -48,7 +48,7 @@
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>temppackage.Main</mainClass>
<mainClass>millions.App</mainClass>
</configuration>
</plugin>
<plugin>
Expand Down
95 changes: 95 additions & 0 deletions src/main/java/millions/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
package millions;

import java.math.BigDecimal;
import java.util.Objects;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.stage.Stage;
import millions.controller.GameController;
import millions.controller.fileIO.InvalidFormatException;
import millions.controller.fileIO.UncheckedFileNotFoundException;
import millions.view.ExitView;
import millions.view.GameView;
import millions.view.StartView;

/** Main JavaFX application entry point for the Millions stock trading game. */
public class App extends Application {
private static final Logger logger = Logger.getLogger(App.class.getName());
private static final String STYLESHEET =
Objects.requireNonNull(App.class.getResource("/styles/millions.css")).toExternalForm();

@Override
public void start(Stage stage) {
GameController controller = new GameController();
StartView startView = new StartView(stage);

startView
.getStartButton()
.setOnAction(
event -> {
try {
controller.startGame(
startView.getName(),
new BigDecimal(startView.getStartingAmount()),
startView.getSelectedFile().toPath(),
startView.getPreRunWeeks());

GameView gameView =
new GameView(
controller,
() -> {
ExitView exitView = new ExitView(controller.getPlayer());
exitView.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
Scene exitScene = new Scene(exitView, 500, 400);
exitScene.getStylesheets().add(STYLESHEET);
stage.setScene(exitScene);
});
controller.getPlayer().addListener(gameView);
controller.getExchange().addListener(gameView);

Scene gameScene = new Scene(gameView, 1920, 1080);
gameScene.getStylesheets().add(STYLESHEET);
stage.setScene(gameScene);
} catch (InvalidFormatException e) {
logger.log(Level.WARNING, "InvalidFormatException: " + e.getMessage());

Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText("Error with selected file");
alert.setContentText(
e.getMessage() + "\nPlease control the format of the selected file");

alert.showAndWait();

} catch (UncheckedFileNotFoundException e) {
logger.log(Level.WARNING, "FileNotFoundException: " + e.getMessage());

Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Error");
alert.setHeaderText("Error with selected file");
alert.setContentText(e.getMessage());

alert.showAndWait();

} catch (RuntimeException ex) {
logger.log(Level.SEVERE, ex.getMessage());
System.exit(0);
}
});

Scene scene = new Scene(startView, 400, 350);
scene.getStylesheets().add(STYLESHEET);
stage.setTitle("Millions");
stage.setMinWidth(900);
stage.setMinHeight(600);
stage.setScene(scene);
stage.show();
}

public static void main(String[] args) {
launch(args);
}
}
68 changes: 0 additions & 68 deletions src/main/java/millions/Exchange.java

This file was deleted.

43 changes: 0 additions & 43 deletions src/main/java/millions/Player.java

This file was deleted.

34 changes: 0 additions & 34 deletions src/main/java/millions/Portfolio.java

This file was deleted.

27 changes: 0 additions & 27 deletions src/main/java/millions/Share.java

This file was deleted.

32 changes: 0 additions & 32 deletions src/main/java/millions/Stock.java

This file was deleted.

Loading

0 comments on commit 810c2fd

Please sign in to comment.