diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Audio/Audio.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Audio/Audio.java
deleted file mode 100644
index 36b9809..0000000
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Audio/Audio.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Audio;
-
-/**
- * Represents a Audio enum.
- */
-public enum Audio {
-
- // Sound effects
- OPEN_APP("/Audio/open_app.wav", true),
- CLOSE_APP("/Audio/close_app.wav", true),
- CLOCK("/Audio/clock.wav", true),
-
- // Background music
- WORK_THEME("/Audio/work_theme.mp3", false),
- WEEKEND_THEME("/Audio/weekend_theme.mp3", false);
-
- private String path;
- private boolean isSFX;
-
- Audio(String path, boolean isSFX) {
- this.path = path;
- this.isSFX = isSFX;
- }
-
- /**
- * Returns the path.
- *
- * @return the value
- */
- public String getPath() {
- return path;
- }
-
- /**
- * Issfx method.
- */
- public boolean isSFX() {
- return isSFX;
- }
-}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/AppStoreController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/AppStoreController.java
deleted file mode 100644
index 06482da..0000000
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/AppStoreController.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers;
-
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.AppStoreApp;
-
-/** Controller for the App Store. */
-public class AppStoreController implements AppController {
- /** Constructs the controller. */
- public AppStoreController(final AppStoreApp appStoreApp) {
- }
-
- /** Processes next tick. */
- @Override
- public void nextTick() {
- }
-}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/BankAppController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/BankAppController.java
deleted file mode 100644
index 1af4bc5..0000000
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/BankAppController.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers;
-
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Player;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.BankApp;
-import javafx.application.Platform;
-
-/** Controller for Bank app. */
-public record BankAppController(BankApp bankApp, Player player) implements AppController {
- /** Constructs the controller. */
- public BankAppController {
- nextTick();
- }
-
- /** Processes next tick. */
- @Override
- public void nextTick() {
- Platform.runLater(() -> {
- bankApp.updateStatus(
- player.getNetWorth().doubleValue(),
- player.getMoney().doubleValue(),
- player.getPortfolio().getNetWorth().doubleValue(),
- player.getStartingMoney().doubleValue()
- );
-
- bankApp.getPortfolioList().getItems().setAll(
- player.getPortfolio().getShares()
- );
- });
- }
-}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Millions.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Millions.java
index cc72c0c..1144111 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Millions.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Millions.java
@@ -1,20 +1,33 @@
package edu.ntnu.idi.idatt2003.gruppe42;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.GameController;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.PopupsController;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.ViewControllers.DesktopViewController;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.ViewControllers.StartViewController;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Difficulty;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.GameFactory;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Player;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Views.DesktopView;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Views.StartView;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.GameController;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.PopupsController;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.viewcontrollers.DesktopViewController;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.viewcontrollers.StartViewController;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Difficulty;
+import edu.ntnu.idi.idatt2003.gruppe42.model.GameFactory;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Player;
+import edu.ntnu.idi.idatt2003.gruppe42.view.views.DesktopView;
+import edu.ntnu.idi.idatt2003.gruppe42.view.views.StartView;
import java.nio.file.Path;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
-/** JavaFX application entry point. */
+/**
+ * Main JavaFX application entry point for the Millions game.
+ *
+ *
This class is responsible for:
+ *
+ * Launching the JavaFX application
+ * Initializing the start screen
+ * Starting and resetting game sessions
+ * Switching between StartView and DesktopView
+ * Managing global game state lifecycle
+ *
+ *
+ * It acts as the top-level coordinator between views and controllers.
+ */
public class Millions extends Application {
private Scene scene;
@@ -25,7 +38,11 @@ public class Millions extends Application {
private DesktopView desktopView;
private DesktopViewController desktopViewController;
- /** Start method. */
+ /**
+ * Initializes and displays the start screen when the application launches.
+ *
+ * @param stage the primary JavaFX stage
+ */
@Override
public void start(final Stage stage) {
StartView startView = installStartView();
@@ -38,19 +55,35 @@ public void start(final Stage stage) {
stage.show();
}
- /** Begins a new game session. */
- public void initGame(final String username, final Difficulty difficulty, Path userSelectedPath, PopupsController popupsController) {
+ /**
+ * Initializes a new game session using the selected settings.
+ *
+ *
This includes creating the player, starting the game controller,
+ * and switching the scene to the desktop view.
+ *
+ * @param username the player name
+ * @param difficulty selected game difficulty
+ * @param userSelectedPath path to stock data file
+ * @param popupsController controller managing popups
+ */
+ public void initGame(final String username, final Difficulty difficulty,
+ Path userSelectedPath, PopupsController popupsController) {
player = GameFactory.createPlayer(username, difficulty);
gameController = new GameController();
gameController.startGame();
- desktopViewController = new DesktopViewController(player, gameController, userSelectedPath, popupsController);
+ desktopViewController = new DesktopViewController(player, gameController,
+ userSelectedPath, popupsController);
desktopViewController.setOnGameOver(this::resetGame);
desktopView = desktopViewController.getDesktopView();
scene.setRoot(desktopView.getRoot());
}
- /** Centralised reset path. */
+ /**
+ * Resets the game back to the start screen.
+ *
+ *
Stops the running game controller and clears all active state.
+ */
public void resetGame() {
if (gameController != null) {
gameController.stopGame();
@@ -64,22 +97,24 @@ public void resetGame() {
scene.setRoot(startView.getRoot());
}
- /** Builds a fresh StartView. */
+ /**
+ * Creates and initializes a fresh StartView instance.
+ *
+ * @return a new StartView connected to its controller
+ */
private StartView installStartView() {
StartView startView = new StartView();
new StartViewController(this, startView);
return startView;
}
- /** Stop method. */
+ /**
+ * Stops the application and terminates any running game session.
+ */
@Override
public void stop() {
if (gameController != null) {
gameController.stopGame();
}
}
-
- public static void main(final String[] args) {
- launch(args);
- }
}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Day.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Day.java
deleted file mode 100644
index a81bebc..0000000
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Day.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
-
-/**
- * Represents a Day enum.
- */
-public enum Day {
- MON, TUE, WED, THU, FRI, SAT, SUN;
-}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Difficulty.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Difficulty.java
deleted file mode 100644
index 1d3cb52..0000000
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Difficulty.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
-
-/**
- * Represents the game difficulty levels.
- */
-public enum Difficulty {
- EASY,
- MEDIUM,
- HARD;
-}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/EventBus.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/EventBus.java
deleted file mode 100644
index 5c7fa20..0000000
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/EventBus.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Consumer;
-
-public class EventBus {
- private static final EventBus INSTANCE = new EventBus();
- private final Map, List>> listeners = new HashMap<>();
-
- public static EventBus get() { return INSTANCE; }
-
- @SuppressWarnings("unchecked")
- public void subscribe(Class type, Consumer listener) {
- listeners.computeIfAbsent(type, k -> new ArrayList<>())
- .add((Consumer) listener);
- }
-
- public void publish(Object event) {
- List> handlers = listeners.get(event.getClass());
- if (handlers != null) handlers.forEach(h -> h.accept(event));
- }
-}
\ No newline at end of file
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Exchange.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Exchange.java
deleted file mode 100644
index e4b3d60..0000000
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Exchange.java
+++ /dev/null
@@ -1,107 +0,0 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
-
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction.Purchase;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction.Sale;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction.Transaction;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/** Represents a stock exchange. */
-public class Exchange {
- /** The current week in the simulation. */
- private int week;
- /** Map of stock symbols to Stock objects. */
- private final Map stockMap;
-
-
- /** Constructs the exchange. */
- public Exchange(final List stocks) {
- this.week = 0;
- this.stockMap = new HashMap();
- for (Stock stock : stocks) {
- stockMap.put(stock.getSymbol(), stock);
- }
- }
-
- /** @return the current week. */
- public int getWeek() {
- return week;
- }
-
- /** @return true if exchange has stock. */
- public boolean hasStock(final String symbol) {
- return stockMap.containsKey(symbol);
- }
-
- /** @return the stock for given symbol. */
- public Stock getStock(final String symbol) {
- return stockMap.get(symbol);
- }
-
- /** @return matching stocks. */
- public List findStocks(final String searchTerm) {
- List foundStocks = new ArrayList<>();
- String lowerSearchTerm = searchTerm.toLowerCase();
-
- for (Stock stock : stockMap.values()) {
- if (stock.getCompany().toLowerCase().contains(lowerSearchTerm)
- || stock.getSymbol().toLowerCase().contains(lowerSearchTerm)) {
- foundStocks.add(stock);
- }
- }
- return foundStocks;
- }
-
- /** @return all stocks. */
- public List getAllStocks() {
- return new ArrayList<>(stockMap.values());
- }
-
- /** @return purchase transaction. */
- public Transaction buy(
- final String symbol,
- final BigDecimal quantity
- ) {
- Stock stock = getStock(symbol);
- BigDecimal purchasePrice = stock.getSalesPrice();
-
- Share share = new Share(stock, quantity, purchasePrice);
- return new Purchase(share, week);
- }
-
- /** @return sale transaction. */
- public Transaction sell(
- final Share share,
- final BigDecimal quantity,
- final Player player
- ) {
- Share shareToSell = new Share(
- share.getStock(), quantity, share.getPurchasePrice()
- );
- return new Sale(shareToSell, week);
- }
-
- /** Advances simulation by one week. */
- public void advance() {
- week += 1;
- }
-
- /** @return stocks by gain. */
- public List getGainers() {
- return stockMap.values().stream()
- .sorted((a, b) -> b.getLatestPriceChange()
- .compareTo(a.getLatestPriceChange()))
- .toList();
- }
-
- /** @return stocks by loss. */
- public List getLosers() {
- return stockMap.values().stream()
- .sorted(Comparator.comparing(Stock::getLatestPriceChange))
- .toList();
- }
-}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/GameState.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/GameState.java
deleted file mode 100644
index 08e1f6a..0000000
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/GameState.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
-
-/**
- * Represents a GameState enum.
- */
-public enum GameState {
- WORKDAY, RENTDAY, FREEDAY
-}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/StockEvent.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/StockEvent.java
deleted file mode 100644
index ec059b9..0000000
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/StockEvent.java
+++ /dev/null
@@ -1,3 +0,0 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
-
-public record StockEvent(String company, int trend) {}
\ No newline at end of file
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/audio/Audio.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/audio/Audio.java
new file mode 100644
index 0000000..c093d2b
--- /dev/null
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/audio/Audio.java
@@ -0,0 +1,42 @@
+package edu.ntnu.idi.idatt2003.gruppe42.audio;
+
+/**
+ * Represents an audio asset used in the game, either a sound effect or background music track.
+ */
+public enum Audio {
+
+ // Sound effects
+ OPEN_APP("/Audio/open_app.wav", true),
+ CLOSE_APP("/Audio/close_app.wav", true),
+ CLOCK("/Audio/clock.wav", true),
+
+ // Background music
+ WORK_THEME("/Audio/work_theme.mp3", false),
+ WEEKEND_THEME("/Audio/weekend_theme.mp3", false);
+
+ private final String path;
+ private final boolean isSfx;
+
+ Audio(String path, boolean isSfx) {
+ this.path = path;
+ this.isSfx = isSfx;
+ }
+
+ /**
+ * Returns the resource path to the audio file.
+ *
+ * @return the path to the audio file.
+ */
+ public String getPath() {
+ return path;
+ }
+
+ /**
+ * Returns whether this audio is a sound effect.
+ *
+ * @return {@code true} if this is a sound effect, {@code false} if it is background music.
+ */
+ public boolean isSfx() {
+ return isSfx;
+ }
+}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Audio/AudioManager.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/audio/AudioManager.java
similarity index 58%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Audio/AudioManager.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/audio/AudioManager.java
index bd02f21..5e06cd8 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Audio/AudioManager.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/audio/AudioManager.java
@@ -1,8 +1,9 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Audio;
+package edu.ntnu.idi.idatt2003.gruppe42.audio;
import java.io.IOException;
import java.util.EnumMap;
import java.util.Map;
+import java.util.Objects;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.scene.media.Media;
@@ -13,7 +14,10 @@
import javax.sound.sampled.LineEvent;
/**
- * Represents a AudioManager class.
+ * Singleton manager for all game audio, including sound effects and background music.
+ *
+ * Sound effects are pre-cached on startup for low-latency playback.
+ * Background music loops indefinitely and is played at half the master volume.
*/
public final class AudioManager {
@@ -27,7 +31,7 @@ public final class AudioManager {
private AudioManager() {
for (Audio audio : Audio.values()) {
- if (audio.isSFX()) {
+ if (audio.isSfx()) {
try (var stream = getClass().getResourceAsStream(audio.getPath())) {
if (stream != null) {
sfxCache.put(audio, stream.readAllBytes());
@@ -46,15 +50,26 @@ private AudioManager() {
});
}
- public static AudioManager get() { return INSTANCE; }
-
+ /**
+ * Returns the singleton instance of AudioManager.
+ *
+ * @return the shared AudioManager instance.
+ */
+ public static AudioManager get() {
+ return INSTANCE;
+ }
/**
- * Playsfx method.
+ * Plays a sound effect on a separate thread.
+ * Volume is scaled by both master and SFX volume properties.
+ *
+ * @param audio the sound effect to play.
*/
- public void playSFX(final Audio audio) {
+ public void playSfx(final Audio audio) {
byte[] data = sfxCache.get(audio);
- if (data == null) return;
+ if (data == null) {
+ return;
+ }
double volume = masterVolume.get() * sfxVolume.get();
@@ -73,7 +88,9 @@ public void playSFX(final Audio audio) {
}
clip.addLineListener(e -> {
- if (e.getType() == LineEvent.Type.STOP) clip.close();
+ if (e.getType() == LineEvent.Type.STOP) {
+ clip.close();
+ }
});
clip.start();
@@ -83,13 +100,15 @@ public void playSFX(final Audio audio) {
}, "sfx-thread").start();
}
-
/**
- * Playbgmusic method.
+ * Starts looping background music for the given audio track.
+ * Any currently playing background music is stopped first.
+ *
+ * @param audio the background music track to play.
*/
public void playBgMusic(final Audio audio) {
stopBgMusic();
- String url = getClass().getResource(audio.getPath()).toExternalForm();
+ String url = Objects.requireNonNull(getClass().getResource(audio.getPath())).toExternalForm();
bgPlayer = new MediaPlayer(new Media(url));
bgPlayer.setVolume(masterVolume.get() * 0.5);
bgPlayer.setCycleCount(MediaPlayer.INDEFINITE);
@@ -97,7 +116,7 @@ public void playBgMusic(final Audio audio) {
}
/**
- * Stopbgmusic method.
+ * Stops and disposes the currently playing background music.
*/
public void stopBgMusic() {
if (bgPlayer != null) {
@@ -107,46 +126,52 @@ public void stopBgMusic() {
}
}
-
/**
- * Mastervolumeproperty method.
- */
- public DoubleProperty masterVolumeProperty() { return masterVolume; }
- /**
- * Sfxvolumeproperty method.
+ * Returns the master volume.
+ *
+ * @return the master volume (range 0.0–1.0).
*/
- public DoubleProperty sfxVolumeProperty() { return sfxVolume; }
+ public double getMasterVolume() {
+ return masterVolume.get();
+ }
/**
- * Returns the mastervolume.
+ * Returns the current SFX volume.
*
- * @return the value
+ * @return the SFX volume (range 0.0–1.0).
*/
- public double getMasterVolume() { return masterVolume.get(); }
+ public double getSfxVolume() {
+ return sfxVolume.get();
+ }
+
/**
- * Returns the sfxvolume.
+ * Sets the master volume, clamped to the range 0.0–1.0.
*
- * @return the value
+ * @param volume the desired master volume.
*/
- public double getSfxVolume() { return sfxVolume.get(); }
+ public void setMasterVolume(final double volume) {
+ masterVolume.set(clamp(volume));
+ }
/**
- * Sets the mastervolume.
+ * Sets the SFX volume, clamped to the range 0.0–1.0.
*
- * @param v the new value
+ * @param volume the desired SFX volume.
*/
- public void setMasterVolume(final double v) { masterVolume.set(clamp(v)); }
+ public void setSfxVolume(final double volume) {
+ sfxVolume.set(clamp(volume));
+ }
+
/**
- * Sets the sfxvolume.
+ * Converts a linear volume in the range 0.0–1.0 to decibels.
*
- * @param v the new value
+ * @param volume the linear volume to convert.
+ * @return the volume expressed in decibels.
*/
- public void setSfxVolume(final double v) { sfxVolume.set(clamp(v)); }
-
-
- /** Converts a 0.0–1.0 linear volume to decibels for FloatControl. */
private static float volumeToDb(final double volume) {
- if (volume <= 0.0) return -80.0f;
+ if (volume <= 0.0) {
+ return -80.0f;
+ }
return (float) (20.0 * Math.log10(volume));
}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/GameController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/GameController.java
similarity index 56%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/GameController.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/GameController.java
index 3907365..8c751ff 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/GameController.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/GameController.java
@@ -1,15 +1,20 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Controller;
+package edu.ntnu.idi.idatt2003.gruppe42.controller;
-import edu.ntnu.idi.idatt2003.gruppe42.Audio.Audio;
-import edu.ntnu.idi.idatt2003.gruppe42.Audio.AudioManager;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers.AppController;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.GameState;
+import edu.ntnu.idi.idatt2003.gruppe42.audio.Audio;
+import edu.ntnu.idi.idatt2003.gruppe42.audio.AudioManager;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.appcontrollers.AppController;
+import edu.ntnu.idi.idatt2003.gruppe42.model.GameState;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
-/** Controller for the main game loop. */
+/**
+ * Controls the main game loop, managing tick-based updates and background music.
+ *
+ *
Registered {@link AppController} instances are notified on each tick,
+ * and background music is switched automatically based on the current game state.
+ */
public final class GameController {
private final List appControllers = new ArrayList<>();
@@ -19,12 +24,22 @@ public final class GameController {
private boolean workMusicPlaying = false;
private boolean weekendMusicPlaying = false;
- /** Adds an app controller. */
+ /**
+ * Registers an app controller to receive tick updates.
+ *
+ * @param appController the controller to add.
+ */
public void addAppController(final AppController appController) {
appControllers.add(appController);
}
- /** Sets the game state. */
+ /**
+ * Sets the current game state and switches background music accordingly.
+ *
+ * Work theme plays on workdays; weekend theme plays on free days.
+ *
+ * @param gameState the new game state.
+ */
public void setGameState(final GameState gameState) {
this.gameState = gameState;
@@ -41,14 +56,17 @@ public void setGameState(final GameState gameState) {
}
}
- /** Starts the game loop. */
+ /**
+ * Starts the game loop, ticking all registered controllers once per second.
+ *
+ *
The loop stops automatically when a weekend state is detected.
+ */
public void startGame() {
timer = new Timer(true);
final int delay = 0;
final int period = 1000;
timer.scheduleAtFixedRate(new TimerTask() {
- /** Processes game tick. */
@Override
public void run() {
for (AppController controller : appControllers) {
@@ -61,7 +79,9 @@ public void run() {
}, delay, period);
}
- /** Stops the game loop. */
+ /**
+ * Stops the game loop and cancels any pending ticks.
+ */
public void stopGame() {
if (timer != null) {
timer.cancel();
@@ -69,7 +89,11 @@ public void stopGame() {
}
}
- /** @return true if weekend. */
+ /**
+ * Returns whether the current game state is a weekend.
+ *
+ * @return {@code true} if the game state is not {@link GameState#WORKDAY}.
+ */
public boolean isWeekend() {
return gameState != GameState.WORKDAY;
}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/MarketController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/MarketController.java
similarity index 57%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/MarketController.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/MarketController.java
index 1c1b12b..5159d33 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/MarketController.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/MarketController.java
@@ -1,19 +1,25 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Controller;
+package edu.ntnu.idi.idatt2003.gruppe42.controller;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Exceptions.StockFileParseException;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Exchange;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Stock;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.StockFileHandler;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Exchange;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Stock;
+import edu.ntnu.idi.idatt2003.gruppe42.model.StockFileHandler;
+import edu.ntnu.idi.idatt2003.gruppe42.model.exceptions.StockFileParseException;
import java.io.IOException;
import java.nio.file.Path;
import java.util.List;
-/** Controller for the stock market. */
+/**
+ * Controller class for managing the stock market exchange.
+ */
public final class MarketController {
private Exchange exchange;
private final int stockResolution;
- /** Constructs and starts the market. */
+ /**
+ * Creates a new market controller and loads stock data from a file.
+ *
+ * @param path the path to the stock data file
+ */
public MarketController(Path path) {
this.stockResolution = 120;
try {
@@ -27,17 +33,23 @@ public MarketController(Path path) {
}
}
- /** @return the exchange. */
public Exchange getExchange() {
return exchange;
}
- /** Searches for matching stocks. */
+ /**
+ * Searches the market for stocks matching the given search term.
+ *
+ * @param searchTerm the search term to use
+ * @return a list of matching stocks
+ */
public List getMarket(final String searchTerm) {
return exchange.findStocks(searchTerm);
}
- /** Updates stock prices and graphs. */
+ /**
+ * Updates all stock prices and stock graphs in the market.
+ */
public void updateMarket() {
for (Stock stock : exchange.getAllStocks()) {
stock.updatePrice();
@@ -45,7 +57,9 @@ public void updateMarket() {
}
}
- /** Performs initial updates. */
+ /**
+ * Initializes the market by generating stock history and graphs.
+ */
public void startMarket() {
for (Stock stock : exchange.getAllStocks()) {
stock.fakeHistory(stockResolution);
@@ -54,14 +68,9 @@ public void startMarket() {
}
}
- /** Prints market history. */
- public static void printMarket(final List stocks) {
- for (Stock stock : stocks) {
- System.out.println(stock.getHistoricalPrices().toString());
- }
- }
-
- /** Advances the week. */
+ /**
+ * Advances the market by one week.
+ */
public void advanceWeek() {
exchange.advance();
}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/PopupsController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/PopupsController.java
similarity index 65%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/PopupsController.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/PopupsController.java
index 2c28b66..c9669c6 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/PopupsController.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/PopupsController.java
@@ -1,31 +1,42 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Controller;
+package edu.ntnu.idi.idatt2003.gruppe42.controller;
-import edu.ntnu.idi.idatt2003.gruppe42.Audio.Audio;
-import edu.ntnu.idi.idatt2003.gruppe42.Audio.AudioManager;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
+import edu.ntnu.idi.idatt2003.gruppe42.audio.Audio;
+import edu.ntnu.idi.idatt2003.gruppe42.audio.AudioManager;
+import edu.ntnu.idi.idatt2003.gruppe42.model.App;
+import edu.ntnu.idi.idatt2003.gruppe42.view.Popup;
import java.util.List;
import java.util.Optional;
import javafx.geometry.Point2D;
import javafx.scene.control.Button;
import javafx.scene.layout.Pane;
-/** Manages popup behavior. */
+/**
+ * Controller responsible for managing popup windows.
+ */
public final class PopupsController {
private final List popups;
- private AudioManager audioManager = AudioManager.get();
+ private final AudioManager audioManager = AudioManager.get();
+ /**
+ * Creates a new popup controller.
+ *
+ * @param popups the list of popups to manage
+ */
public PopupsController(List popups) {
this.popups = popups;
popups.forEach(this::initPopup);
}
+ /**
+ * Initializes popup behavior such as dragging and closing.
+ *
+ * @param popup the popup to initialize
+ */
private void initPopup(Popup popup) {
makeDraggable(popup);
popup.getCloseButton().setOnAction(event -> hide(popup.getType()));
- // Keep in bounds when parent resizes
Pane root = popup.getRoot();
root.parentProperty().addListener((obs, oldP, newP) -> {
if (newP instanceof Pane parent) {
@@ -35,7 +46,12 @@ private void initPopup(Popup popup) {
});
}
- /** Shows a popup. */
+ /**
+ * Shows the popup matching the given application type.
+ *
+ * @param type the popup type to show
+ * @return true if the popup type was valid, otherwise false
+ */
public boolean show(App type) {
if (type == null) {
return false;
@@ -47,28 +63,41 @@ public boolean show(App type) {
popup.show();
keepInBounds(popup);
});
- audioManager.playSFX(Audio.OPEN_APP);
+ audioManager.playSfx(Audio.OPEN_APP);
return true;
}
- /** Hides a popup. */
- public boolean hide(App type) {
+ /**
+ * Hides the popup matching the given application type.
+ *
+ * @param type the popup type to hide
+ */
+ public void hide(App type) {
if (type == null) {
- return false;
+ return;
}
popups.stream()
.filter(popup -> popup.getType().equals(type))
.findFirst()
.ifPresent(Popup::hide);
- audioManager.playSFX(Audio.CLOSE_APP);
- return true;
+ audioManager.playSfx(Audio.CLOSE_APP);
}
- /** Binds button to show popup. */
+ /**
+ * Binds a button to open a popup.
+ *
+ * @param button the button to bind
+ * @param type the popup type to show when clicked
+ */
public void bindOpenButton(Button button, App type) {
button.setOnAction(event -> show(type));
}
+ /**
+ * Makes a popup draggable within its parent bounds.
+ *
+ * @param popup the popup to make draggable
+ */
private void makeDraggable(Popup popup) {
Pane root = popup.getRoot();
double[] offset = new double[2];
@@ -104,6 +133,11 @@ private void makeDraggable(Popup popup) {
});
}
+ /**
+ * Ensures a popup remains within the bounds of its parent pane.
+ *
+ * @param popup the popup to constrain
+ */
private void keepInBounds(Popup popup) {
Pane root = popup.getRoot();
if (root.layoutXProperty().isBound()) {
@@ -121,24 +155,42 @@ private void keepInBounds(Popup popup) {
}
}
- /** Adds popups. */
+ /**
+ * Adds multiple popups to the controller.
+ *
+ * @param popups the popups to add
+ */
public void addPopups(List popups) {
popups.forEach(this::addPopup);
}
- /** Adds a popup. */
+ /**
+ * Adds a popup to the controller.
+ *
+ * @param popup the popup to add
+ */
public void addPopup(Popup popup) {
initPopup(popup);
this.popups.add(popup);
}
- /** @return the popup. */
+ /**
+ * Returns the popup matching the given type.
+ *
+ * @param type the popup type
+ * @return the matching popup, or null if none exists
+ */
public Popup getPopup(App type) {
- Optional match = popups.stream().filter(popup -> popup.getType().equals(type)).findFirst();
+ Optional match = popups.stream().filter(popup -> popup.getType()
+ .equals(type)).findFirst();
return match.orElse(null);
}
- /** @return the popups. */
+ /**
+ * Returns all managed popups.
+ *
+ * @return the list of popups
+ */
public List getPopups() {
return popups;
}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/StockController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/StockController.java
similarity index 71%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/StockController.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/StockController.java
index 5432fa0..e06705f 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/StockController.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/StockController.java
@@ -1,16 +1,18 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Controller;
+package edu.ntnu.idi.idatt2003.gruppe42.controller;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.EventBus;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Stock;
-
-import edu.ntnu.idi.idatt2003.gruppe42.Model.StockEvent;
+import edu.ntnu.idi.idatt2003.gruppe42.model.EventBus;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Stock;
+import edu.ntnu.idi.idatt2003.gruppe42.model.StockEvent;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Random;
+/**
+ * Controller responsible for simulating and updating stock prices.
+ */
public class StockController {
- private static final int STEEP_THRESHOLD = 45;
+ private static final int STEEP_THRESHOLD = 46;
private static final int EVENT_MAGNITUDE = 90;
private static final double NOISE_RANGE = 8.0;
private static final int MIN_TREND_FRAMES = 10;
@@ -21,20 +23,28 @@ public class StockController {
private int trendFramesRemaining;
private int trend;
private int delay;
- private Random random;
+ private final Random random;
private BigDecimal price;
- private BigDecimal startPrice;
private BigDecimal pendingShock;
+ /**
+ * Creates a new stock controller.
+ *
+ * @param stock the stock to manage
+ */
public StockController(final Stock stock) {
this.stock = stock;
this.delay = 0;
this.random = new Random();
- this.startPrice = stock.getSalesPrice();
- this.price = startPrice;
+ this.price = stock.getSalesPrice();
nextTrend();
}
+ /**
+ * Updates and returns the current stock price.
+ *
+ * @return the updated stock price
+ */
public BigDecimal updatePrice() {
BigDecimal noise = BigDecimal.valueOf((random.nextDouble() * 2 - 1) * NOISE_RANGE);
@@ -75,6 +85,9 @@ public BigDecimal updatePrice() {
return price.setScale(2, RoundingMode.HALF_UP);
}
+ /**
+ * Generates the next stock trend.
+ */
private void nextTrend() {
trend = random.nextInt(101) - 50;
trendTimeframe = random.nextInt(120) + MIN_TREND_FRAMES;
@@ -89,6 +102,9 @@ private void nextTrend() {
}
}
+ /**
+ * Prepares a stock event and schedules a price shock.
+ */
private void prepareEvent() {
int direction = trend > 0 ? 1 : -1;
double scaledMagnitude = EVENT_MAGNITUDE * ((double) Math.abs(trend) / 50.0);
@@ -97,10 +113,20 @@ private void prepareEvent() {
.publish(new StockEvent(stock.getCompany(), trend));
}
+ /**
+ * Checks whether the current trend is steep.
+ *
+ * @return true if the trend exceeds the steep threshold
+ */
private boolean isTrajectorySteep() {
return Math.abs(trend) > STEEP_THRESHOLD;
}
+ /**
+ * Checks whether the controller is currently delaying a shock.
+ *
+ * @return true if delay is active
+ */
private boolean isDelay() {
return delay > 0;
}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/TimeAndWeatherController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/TimeAndWeatherController.java
similarity index 62%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/TimeAndWeatherController.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/TimeAndWeatherController.java
index 62bd2b6..f05df71 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/TimeAndWeatherController.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/TimeAndWeatherController.java
@@ -1,10 +1,10 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Controller;
+package edu.ntnu.idi.idatt2003.gruppe42.controller;
-import edu.ntnu.idi.idatt2003.gruppe42.Audio.Audio;
-import edu.ntnu.idi.idatt2003.gruppe42.Audio.AudioManager;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers.AppController;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Day;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.GameState;
+import edu.ntnu.idi.idatt2003.gruppe42.audio.Audio;
+import edu.ntnu.idi.idatt2003.gruppe42.audio.AudioManager;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.appcontrollers.AppController;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Day;
+import edu.ntnu.idi.idatt2003.gruppe42.model.GameState;
import java.util.Random;
import javafx.application.Platform;
import javafx.beans.property.IntegerProperty;
@@ -12,7 +12,9 @@
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
-/** Manages game time and weather. */
+/**
+ * Controller responsible for managing in-game time, days, weeks, and weather.
+ */
public class TimeAndWeatherController implements AppController {
private final IntegerProperty hour = new SimpleIntegerProperty(0);
private final IntegerProperty dayIndex = new SimpleIntegerProperty(0);
@@ -21,17 +23,24 @@ public class TimeAndWeatherController implements AppController {
private final StringProperty weather = new SimpleStringProperty("Sunny");
private final Random random = new Random();
private final GameController gameController;
- private AudioManager audioManager = AudioManager.get();
+ private final AudioManager audioManager = AudioManager.get();
private static final Day[] DAYS = {Day.SUN, Day.MON, Day.TUE, Day.WED, Day.THU, Day.FRI, Day.SAT};
+ /**
+ * Creates a new time and weather controller.
+ *
+ * @param gameController the game controller
+ */
public TimeAndWeatherController(GameController gameController) {
this.gameController = gameController;
updateWeather();
updateGameState();
}
- /** Processes next tick. */
+ /**
+ * Processes the next tick.
+ */
@Override
public void nextTick() {
int nextHour = hour.get() + 1;
@@ -40,15 +49,16 @@ public void nextTick() {
updateGameState();
updateWeather();
hour.set(0);
- Platform.runLater(() -> audioManager.playSFX(Audio.CLOCK));
+ Platform.runLater(() -> audioManager.playSfx(Audio.CLOCK));
} else {
hour.set(nextHour);
}
}
+ /**
+ * Updates the weather and temperature values.
+ */
private void updateWeather() {
- // Basic seasonal/random temperature logic
- // Range from -10 to 30
int change = random.nextInt(11) - 5; // -5 to +5
int newTemp = temperature.get() + change;
newTemp = Math.min(Math.max(newTemp, -10), 30);
@@ -64,22 +74,36 @@ private void updateWeather() {
}
}
- /** @return hour property. */
+ /**
+ * Returns the hour property.
+ *
+ * @return the hour property
+ */
public IntegerProperty hourProperty() {
return hour;
}
- /** @return day index property. */
+ /**
+ * Returns the day index property.
+ *
+ * @return the day index property
+ */
public IntegerProperty dayIndexProperty() {
return dayIndex;
}
- /** @return week index property. */
+ /**
+ * Returns the week number property.
+ *
+ * @return the week number property
+ */
public IntegerProperty weekIndexProperty() {
return weekNumber;
}
- /** Advances the week. */
+ /**
+ * Advances game to next week.
+ */
public void advanceWeek() {
weekNumber.set(weekNumber.get() + 1);
dayIndex.set(1);
@@ -87,32 +111,54 @@ public void advanceWeek() {
gameController.startGame();
}
- /** @return temperature property. */
+ /**
+ * Returns the temperature property.
+ *
+ * @return the temperature property
+ */
public IntegerProperty temperatureProperty() {
return temperature;
}
- /** @return weather property. */
+ /**
+ * Returns the weather property.
+ *
+ * @return the weather property
+ */
public StringProperty weatherProperty() {
return weather;
}
- /** @return time string. */
+ /**
+ * Returns the formatted time string.
+ *
+ * @return the current time as a string
+ */
public String getTimeString() {
return String.format("%02d:00", hour.get());
}
- /** @return day of week string. */
+ /**
+ * Returns the current day of the week as a string.
+ *
+ * @return the current day string
+ */
public String getDayOfWeekString() {
return DAYS[dayIndex.get()].toString();
}
- /** @return week string. */
+ /**
+ * Returns the formatted week string.
+ *
+ * @return the week string
+ */
public String getWeekString() {
return "Week " + weekNumber.get();
}
- /** Updates game state. */
+ /**
+ * Updates the current game state based on the day.
+ */
public void updateGameState() {
if (dayIndex.get() == 6) {
gameController.setGameState(GameState.RENTDAY);
@@ -124,7 +170,11 @@ public void updateGameState() {
gameController.setGameState(GameState.WORKDAY);
}
- /** Sets the day. */
+ /**
+ * Sets the current day index.
+ *
+ * @param index the day index to set
+ */
public void setDay(int index) {
dayIndex.set(index);
updateGameState();
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/AppController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/appcontrollers/AppController.java
similarity index 75%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/AppController.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/appcontrollers/AppController.java
index df8e908..3f1f339 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/AppController.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/appcontrollers/AppController.java
@@ -1,9 +1,10 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers;
+package edu.ntnu.idi.idatt2003.gruppe42.controller.appcontrollers;
/**
* Interface for application controllers that respond to game ticks.
*/
public interface AppController {
+
/**
* Updates the app state on each simulation tick.
*/
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/appcontrollers/AppStoreController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/appcontrollers/AppStoreController.java
new file mode 100644
index 0000000..b63f3d5
--- /dev/null
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/appcontrollers/AppStoreController.java
@@ -0,0 +1,30 @@
+package edu.ntnu.idi.idatt2003.gruppe42.controller.appcontrollers;
+
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.AppStoreApp;
+
+/**
+ * Controller for the App Store application.
+ *
+ * This controller is responsible for managing App Store related logic.
+ * It is currently a placeholder implementation and does not yet contain
+ * active game-time behavior.
+ */
+public class AppStoreController implements AppController {
+
+ /**
+ * Constructs the App Store controller.
+ *
+ * @param appStoreApp the App Store view component
+ */
+ public AppStoreController(final AppStoreApp appStoreApp) {
+ }
+
+ /**
+ * Processes the next game tick for the App Store.
+ *
+ *
Currently no periodic logic is implemented.
+ */
+ @Override
+ public void nextTick() {
+ }
+}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/appcontrollers/BankAppController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/appcontrollers/BankAppController.java
new file mode 100644
index 0000000..36a16e1
--- /dev/null
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/appcontrollers/BankAppController.java
@@ -0,0 +1,46 @@
+package edu.ntnu.idi.idatt2003.gruppe42.controller.appcontrollers;
+
+import edu.ntnu.idi.idatt2003.gruppe42.model.Player;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.BankApp;
+import javafx.application.Platform;
+
+/**
+ * Controller for the Bank application.
+ *
+ *
This controller updates the Bank UI with the player's financial
+ * information, including cash balance, net worth, portfolio value,
+ * and starting capital.
+ *
+ *
It is triggered on each game tick to ensure the UI stays synchronized
+ * with the underlying player model.
+ */
+public record BankAppController(BankApp bankApp, Player player) implements AppController {
+
+ /**
+ * Constructs the Bank app controller and performs an initial UI update.
+ */
+ public BankAppController {
+ nextTick();
+ }
+
+ /**
+ * Updates the Bank application UI with the latest player financial data.
+ *
+ *
This method runs on the JavaFX application thread.
+ */
+ @Override
+ public void nextTick() {
+ Platform.runLater(() -> {
+ bankApp.updateStatus(
+ player.getNetWorth().doubleValue(),
+ player.getMoney().doubleValue(),
+ player.getPortfolio().getNetWorth().doubleValue(),
+ player.getStartingMoney().doubleValue()
+ );
+
+ bankApp.getPortfolioList().getItems().setAll(
+ player.getPortfolio().getShares()
+ );
+ });
+ }
+}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/MailController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/appcontrollers/MailController.java
similarity index 57%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/MailController.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/appcontrollers/MailController.java
index 3fa60a5..0e4016f 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/MailController.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/appcontrollers/MailController.java
@@ -1,8 +1,7 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers;
+package edu.ntnu.idi.idatt2003.gruppe42.controller.appcontrollers;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.TimeAndWeatherController;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Day;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Message;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.TimeAndWeatherController;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Message;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.IntegerBinding;
import javafx.collections.FXCollections;
@@ -10,7 +9,14 @@
import javafx.collections.ObservableList;
/**
- * Controller for the Mail app, managing incoming messages and unread status.
+ * Controller for the Mail application.
+ *
+ *
This controller manages incoming messages, message creation,
+ * and tracking of unread messages in the inbox. It also keeps
+ * messages synchronized with the current in-game time.
+ *
+ *
It provides an observable unread count binding used by the UI
+ * to display notification badges.
*/
public class MailController implements AppController {
private final ObservableList messages = FXCollections.observableArrayList();
@@ -21,16 +27,19 @@ public class MailController implements AppController {
private int time;
/**
- * Constructs the MailController and sets up the unread count binding.
+ * Constructs the MailController and initializes message tracking
+ * and unread count bindings.
+ *
+ * @param timeAndWeatherController controller used for time/date retrieval
*/
public MailController(TimeAndWeatherController timeAndWeatherController) {
this.timeAndWeatherController = timeAndWeatherController;
unreadCount = Bindings.createIntegerBinding(() ->
- (int) messages.stream().filter(m -> !m.isSeen()).count(),
+ (int) messages.stream().filter(Message::isSeen).count(),
messages
);
- // Ensure unreadCount updates when a message's seen property changes
+ // Ensure unreadCount updates when a message is seen property changes
messages.addListener((ListChangeListener) change -> {
while (change.next()) {
if (change.wasAdded()) {
@@ -43,21 +52,27 @@ public MailController(TimeAndWeatherController timeAndWeatherController) {
});
}
- /**
- * @return the list of messages.
- */
public ObservableList getMessages() {
return messages;
}
/**
- * @return a binding to the number of unread messages.
+ * Returns a binding representing the number of unread messages.
+ *
+ * @return integer binding of unread messages
*/
public IntegerBinding unreadCountProperty() {
return unreadCount;
}
-
+ /**
+ * Creates and adds a new message to the inbox using the current
+ * in-game time for timestamping.
+ *
+ * @param author the message sender
+ * @param title the message title
+ * @param message the message content
+ */
public void createMessage(String author, String title, String message) {
updateDateTime();
messages.add(0, new Message(author, title, message, week, day, time));
@@ -69,12 +84,21 @@ public void createMessage(String author, String title, String message) {
public void clearMessages() {
messages.clear();
}
+
+ /**
+ * Updates internal time tracking variables from the time controller.
+ */
public void updateDateTime() {
week = timeAndWeatherController.weekIndexProperty().get();
day = timeAndWeatherController.getDayOfWeekString();
time = timeAndWeatherController.hourProperty().get();
}
+ /**
+ * Processes the next game tick.
+ *
+ * Currently no periodic logic is implemented.
+ */
@Override
public void nextTick() {
}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/SettingsAppController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/appcontrollers/SettingsAppController.java
similarity index 68%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/SettingsAppController.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/appcontrollers/SettingsAppController.java
index 2095d41..35b8555 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/SettingsAppController.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/appcontrollers/SettingsAppController.java
@@ -1,17 +1,31 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers;
-
-import edu.ntnu.idi.idatt2003.gruppe42.Audio.AudioManager;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Exchange;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.StockFileHandler;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.FilePickerApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.SettingsApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.SettingsApp.GradientConfig;
+package edu.ntnu.idi.idatt2003.gruppe42.controller.appcontrollers;
+
+import edu.ntnu.idi.idatt2003.gruppe42.audio.AudioManager;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Exchange;
+import edu.ntnu.idi.idatt2003.gruppe42.model.StockFileHandler;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.FilePickerApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.SettingsApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.SettingsApp.GradientConfig;
import java.nio.file.Path;
import java.util.Objects;
import java.util.function.Consumer;
import javafx.scene.layout.Pane;
-/** Controller for Settings app. */
+/**
+ * Controller for the Settings application.
+ *
+ *
This controller manages user-configurable settings such as:
+ *
+ * Audio volume (master and SFX)
+ * Player name changes
+ * Theme gradient customization
+ * File selection for stock data
+ * Session actions such as logout and power off
+ *
+ *
+ * It also validates selected stock files and falls back to a default file
+ * if validation fails.
+ */
public class SettingsAppController implements AppController {
private Path userSelectedPath;
@@ -26,7 +40,13 @@ public class SettingsAppController implements AppController {
private final SettingsApp settingsApp;
private final FilePickerApp filePickerApp;
- /** Constructs the controller. */
+ /**
+ * Constructs the Settings controller and initializes UI bindings,
+ * file validation, and event wiring.
+ *
+ * @param settingsApp the settings UI view
+ * @param filePickerApp the file picker UI view
+ */
public SettingsAppController(final SettingsApp settingsApp, final FilePickerApp filePickerApp) {
this.settingsApp = settingsApp;
this.filePickerApp = filePickerApp;
@@ -39,16 +59,19 @@ public SettingsAppController(final SettingsApp settingsApp, final FilePickerApp
filePickerApp.setOnFileConfirmed(path -> {
if (isValidStockFile(path)) {
userSelectedPath = path;
- if (onUserSelection != null) onUserSelection.run();
+ if (onUserSelection != null) {
+ onUserSelection.run();
+ }
} else {
- if (onSelectedFileFailed != null) onSelectedFileFailed.run();
+ if (onSelectedFileFailed != null) {
+ onSelectedFileFailed.run();
+ }
userSelectedPath = loadDefaultPath();
}
refreshView();
});
}
-
private void wireControls() {
settingsApp.getMasterVolumeSlider().valueProperty().addListener((obs, ov, nv) ->
AudioManager.get().setMasterVolume(nv.doubleValue() / 100.0));
@@ -78,23 +101,29 @@ private void wireControls() {
});
settingsApp.getLogoutButton().setOnAction(event -> {
- if (onLogout != null) onLogout.run();
+ if (onLogout != null) {
+ onLogout.run();
+ }
});
settingsApp.getPowerOffButton().setOnAction(event -> {
- if (onPowerOff != null) onPowerOff.run();
+ if (onPowerOff != null) {
+ onPowerOff.run();
+ }
});
}
}
- /** Sets the login status. */
+ /**
+ * Enables or disables logged-in mode and rewires UI controls accordingly.
+ *
+ * @param status true if user is logged in, false otherwise
+ */
public void setLoggedIn(final boolean status) {
settingsApp.setLoggedIn(status);
wireControls();
}
-
private void openFilePicker() {
- // Lazily attach the picker to the same parent pane as the settings popup
if (filePickerApp.getRoot().getParent() == null) {
var parent = settingsApp.getRoot().getParent();
if (parent instanceof Pane pane) {
@@ -105,7 +134,6 @@ private void openFilePicker() {
filePickerApp.show();
}
-
private boolean isValidStockFile(final Path path) {
try {
new Exchange(StockFileHandler.readFromFile(path));
@@ -131,54 +159,53 @@ private void refreshView() {
settingsApp.updateContent();
}
-
- /** Sets onUserPathSelected callback. */
public void setOnUserPathSelected(final Runnable callback) {
onUserSelection = callback;
}
- /** Sets onSelectedFileFailed callback. */
public void setOnSelectedFileFailed(final Runnable callback) {
onSelectedFileFailed = callback;
}
- /** Sets onLogout callback. */
public void setOnLogout(final Runnable callback) {
onLogout = callback;
}
- /** Sets onPowerOff callback. */
public void setOnPowerOff(final Runnable callback) {
onPowerOff = callback;
}
- /** Sets onPlayerNameChanged callback. */
public void setOnPlayerNameChanged(final Consumer callback) {
onPlayerNameChanged = callback;
}
- /** Sets onGradientChanged callback. */
public void setOnGradientChanged(final Consumer callback) {
onGradientChanged = callback;
}
-
- /** @return the selected path. */
+ /**
+ * Returns the currently selected stock file path.
+ *
+ * @return selected file path
+ */
public Path getUserSelectedPath() {
return userSelectedPath;
}
- /** @return the file picker. */
- public FilePickerApp getFilePickerApp() {
- return filePickerApp;
- }
-
- /** @return the error message. */
+ /**
+ * Returns the last error message produced during file validation.
+ *
+ * @return error message, or null if no error occurred
+ */
public String getErrorMessage() {
return errorMessage;
}
+ /**
+ * Processes the next game tick.
+ *
+ * This controller does not currently perform any tick-based logic.
+ */
@Override
- /** Processes next tick. */
public void nextTick() {}
}
\ No newline at end of file
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/StockAppController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/appcontrollers/StockAppController.java
similarity index 96%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/StockAppController.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/appcontrollers/StockAppController.java
index 5ede319..513a9ca 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/AppControllers/StockAppController.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/appcontrollers/StockAppController.java
@@ -1,10 +1,10 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers;
+package edu.ntnu.idi.idatt2003.gruppe42.controller.appcontrollers;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.MarketController;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Player;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Stock;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction.Transaction;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.StockApp;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.MarketController;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Player;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Stock;
+import edu.ntnu.idi.idatt2003.gruppe42.model.transaction.Transaction;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.StockApp;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
@@ -290,7 +290,7 @@ private void handleSell(final Stock stock, final BigDecimal quantity) {
return;
}
Transaction transaction =
- marketController.getExchange().sell(existingShare, quantity, player);
+ marketController.getExchange().sell(existingShare, quantity);
if (transaction != null) {
try {
transaction.commit(player);
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopComponentFactory.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/viewcontrollers/DesktopComponentFactory.java
similarity index 78%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopComponentFactory.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/viewcontrollers/DesktopComponentFactory.java
index 0b90deb..f099d48 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopComponentFactory.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/viewcontrollers/DesktopComponentFactory.java
@@ -1,8 +1,8 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Controller.ViewControllers;
+package edu.ntnu.idi.idatt2003.gruppe42.controller.viewcontrollers;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers.MailController;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.PopupsController;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.PopupsController;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.appcontrollers.MailController;
+import edu.ntnu.idi.idatt2003.gruppe42.model.App;
import javafx.beans.binding.Bindings;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
@@ -20,14 +20,16 @@
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
-/** Factory for creating desktop UI components. */
+/**
+ * Factory class for creating desktop user interface components.
+ */
public final class DesktopComponentFactory {
private final PopupsController popupsController;
private final MailController mailController;
/**
- * Constructs the factory.
+ * Constructs a DesktopComponentFactory.
*
* @param popupsController the popups controller
* @param mailController the mail controller
@@ -38,10 +40,10 @@ public DesktopComponentFactory(PopupsController popupsController, MailController
}
/**
- * Creates an app button.
+ * Creates a button representing an application.
*
- * @param type the app type
- * @return the node representing the app button
+ * @param type the application type
+ * @return the created application button node
*/
public Node createAppButton(final App type) {
Button button = new Button(type.getDisplayName());
@@ -51,22 +53,22 @@ public Node createAppButton(final App type) {
Node appNode = button;
if (type == App.MAIL) {
- StackPane container = new StackPane();
-
- Circle badge = new Circle(10, Color.RED);
+ final StackPane container = new StackPane();
+
+ final Circle badge = new Circle(10, Color.RED);
Label countLabel = new Label();
countLabel.setTextFill(Color.WHITE);
countLabel.setFont(Font.font("System", FontWeight.BOLD, 10));
countLabel.textProperty().bind(mailController.unreadCountProperty().asString());
- StackPane badgeUI = new StackPane(badge, countLabel);
- badgeUI.setMouseTransparent(true);
- badgeUI.setAlignment(Pos.CENTER);
- badgeUI.visibleProperty().bind(mailController.unreadCountProperty().greaterThan(0));
+ StackPane badgeUi = new StackPane(badge, countLabel);
+ badgeUi.setMouseTransparent(true);
+ badgeUi.setAlignment(Pos.CENTER);
+ badgeUi.visibleProperty().bind(mailController.unreadCountProperty().greaterThan(0));
- container.getChildren().addAll(button, badgeUI);
- StackPane.setAlignment(badgeUI, Pos.TOP_RIGHT);
- StackPane.setMargin(badgeUI, new Insets(-10, -10, 0, 0));
+ container.getChildren().addAll(button, badgeUi);
+ StackPane.setAlignment(badgeUi, Pos.TOP_RIGHT);
+ StackPane.setMargin(badgeUi, new Insets(-10, -10, 0, 0));
// Bind container size to button size so badge is aligned to button corners
container.prefWidthProperty().bind(button.prefWidthProperty());
@@ -116,7 +118,7 @@ public Node createAppButton(final App type) {
}
/**
- * Configures a stack pane as a drop target for app buttons.
+ * Configures a stack pane to accept dragged application buttons.
*
* @param cell the stack pane to configure
*/
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopDialogController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/viewcontrollers/DesktopDialogController.java
similarity index 65%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopDialogController.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/viewcontrollers/DesktopDialogController.java
index e8a3dc6..7565a80 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopDialogController.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/viewcontrollers/DesktopDialogController.java
@@ -1,17 +1,20 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Controller.ViewControllers;
-
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.TimeAndWeatherController;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Player;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction.Transaction;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.GameOverApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.WarningApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.WeekendReportApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Views.DesktopView;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Views.DesktopView.ModalLayer;
+package edu.ntnu.idi.idatt2003.gruppe42.controller.viewcontrollers;
+
+import edu.ntnu.idi.idatt2003.gruppe42.controller.TimeAndWeatherController;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Player;
+import edu.ntnu.idi.idatt2003.gruppe42.model.transaction.Transaction;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.GameOverApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.WarningApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.WeekendReportApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.views.DesktopView;
+import edu.ntnu.idi.idatt2003.gruppe42.view.views.DesktopView.ModalLayer;
import java.math.BigDecimal;
import java.util.List;
-/** Controller for handling desktop dialogs and modals. */
+/**
+ * Controller responsible for managing desktop dialogs, modals, and user-facing game events such
+ * as warnings, weekend reports, and game over screens.
+ */
public final class DesktopDialogController {
private static final BigDecimal WEEKLY_RENT = new BigDecimal("50.00");
@@ -26,13 +29,13 @@ public final class DesktopDialogController {
private Runnable onAdvanceWeek;
/**
- * Constructs the controller.
+ * Constructs a new desktop dialog controller.
*
* @param player the player model
* @param timeAndWeatherController the time and weather controller
- * @param weekendReportApp the weekend rapport app
- * @param warningApp the warning app
- * @param gameOverApp the game over app
+ * @param weekendReportApp the weekend report UI
+ * @param warningApp the warning UI
+ * @param gameOverApp the game over UI
*/
public DesktopDialogController(
Player player,
@@ -50,19 +53,36 @@ public DesktopDialogController(
wireGameOver();
}
+ /**
+ * Sets the desktop view used for modal layering.
+ *
+ * @param desktopView the desktop view
+ */
public void setDesktopView(DesktopView desktopView) {
this.desktopView = desktopView;
}
+ /**
+ * Sets the callback executed when the game ends.
+ *
+ * @param onGameOver callback to execute on game over
+ */
public void setOnGameOver(Runnable onGameOver) {
this.onGameOver = onGameOver;
}
+ /**
+ * Sets the callback executed when advancing to the next week.
+ *
+ * @param onAdvanceWeek callback to execute when advancing week
+ */
public void setOnAdvanceWeek(Runnable onAdvanceWeek) {
this.onAdvanceWeek = onAdvanceWeek;
}
- /** Shows the weekend rapport. */
+ /**
+ * Displays the weekend report, including income, rent deduction, and transaction history.
+ */
public void showWeekendRapport() {
int week = timeAndWeatherController.weekIndexProperty().get();
BigDecimal netIncome = player.getTransactionArchive().calculateNetIncome(week);
@@ -77,6 +97,9 @@ public void showWeekendRapport() {
desktopView.enterLayer(ModalLayer.RAPPORT);
}
+ /**
+ * Wires the weekend report continue button to reset the day and close the modal.
+ */
private void wireWeekendRapport() {
weekendReportApp.getContinueButton().setOnAction(event -> {
weekendReportApp.getRoot().setVisible(false);
@@ -85,7 +108,10 @@ private void wireWeekendRapport() {
});
}
- /** Shows the debt warning. */
+ /**
+ * Displays a warning about starting the week in debt.
+ * Choosing to proceed may reduce player lives.
+ */
public void showDebtWarning() {
warningApp.configure(
"💔",
@@ -107,7 +133,9 @@ public void showDebtWarning() {
showWarning();
}
- /** Shows the market closed warning. */
+ /**
+ * Shows a warning that the market is closed during weekends.
+ */
public void showMarketClosedWarning() {
warningApp.configure(
"🔒",
@@ -119,10 +147,12 @@ public void showMarketClosedWarning() {
showWarning();
}
- /** Shows the insufficient funds warning. */
+ /**
+ * Shows a warning when the player has insufficient funds.
+ */
public void showInsufficientFundsWarning() {
warningApp.configure(
- "\uD83E\uDD7A",
+ "🥺",
"Insufficient Funds",
"You don't have enough cash to complete this purchase.",
"I'll be back"
@@ -131,27 +161,36 @@ public void showInsufficientFundsWarning() {
showWarning();
}
- /** Shows a warning. */
+ /**
+ * Displays a generic warning modal.
+ */
public void showWarning() {
warningApp.show();
desktopView.enterLayer(ModalLayer.WARNING);
}
- /** Dismisses a warning. */
+ /**
+ * Dismisses the currently shown warning modal.
+ */
public void dismissWarning() {
warningApp.getRoot().setVisible(false);
desktopView.exitLayer(ModalLayer.WARNING);
}
- /** Shows the game over screen. */
+ /** Displays the game over screen. */
public void showGameOver() {
gameOverApp.show();
desktopView.enterLayer(ModalLayer.GAME_OVER);
}
+ /**
+ * Wires the game over restart button to the restart callback.
+ */
private void wireGameOver() {
gameOverApp.getStartOverButton().setOnAction(event -> {
- if (onGameOver != null) onGameOver.run();
+ if (onGameOver != null) {
+ onGameOver.run();
+ }
});
}
}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopViewController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/viewcontrollers/DesktopViewController.java
similarity index 69%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopViewController.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/viewcontrollers/DesktopViewController.java
index 24303ba..7e340f4 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/DesktopViewController.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/viewcontrollers/DesktopViewController.java
@@ -1,33 +1,33 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Controller.ViewControllers;
-
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers.AppStoreController;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers.BankAppController;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers.MailController;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers.SettingsAppController;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers.StockAppController;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.GameController;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.MarketController;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.PopupsController;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.TimeAndWeatherController;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.EventBus;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.News;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Player;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.StockEvent;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.AppStoreApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.BankApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.FilePickerApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.GameOverApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.HustlersApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.MailApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.NewsApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.SettingsApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.StockApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.WarningApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.WeekendReportApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Views.DesktopView;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Views.DesktopView.ModalLayer;
+package edu.ntnu.idi.idatt2003.gruppe42.controller.viewcontrollers;
+
+import edu.ntnu.idi.idatt2003.gruppe42.controller.GameController;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.MarketController;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.PopupsController;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.TimeAndWeatherController;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.appcontrollers.AppStoreController;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.appcontrollers.BankAppController;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.appcontrollers.MailController;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.appcontrollers.SettingsAppController;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.appcontrollers.StockAppController;
+import edu.ntnu.idi.idatt2003.gruppe42.model.App;
+import edu.ntnu.idi.idatt2003.gruppe42.model.EventBus;
+import edu.ntnu.idi.idatt2003.gruppe42.model.News;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Player;
+import edu.ntnu.idi.idatt2003.gruppe42.model.StockEvent;
+import edu.ntnu.idi.idatt2003.gruppe42.view.Popup;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.AppStoreApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.BankApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.FilePickerApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.GameOverApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.HustlersApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.MailApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.NewsApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.SettingsApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.StockApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.WarningApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.WeekendReportApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.views.DesktopView;
+import edu.ntnu.idi.idatt2003.gruppe42.view.views.DesktopView.ModalLayer;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
@@ -36,7 +36,21 @@
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
-/** Controller for the desktop view. */
+/**
+ * Controller responsible for managing the entire desktop view, including
+ * application initialization, popup handling, modal dialogs, game progression,
+ * and coordination between UI components and game logic.
+ *
+ *
This class acts as the central integration layer between:
+ *
+ * Game logic (Player, GameController, TimeAndWeatherController)
+ * Market and financial systems (MarketController)
+ * UI systems (DesktopView, Popups, Apps, and Modals)
+ * Application controllers (Stock, Bank, Mail, Settings, etc.)
+ *
+ *
+ * It also handles event-driven updates such as stock events and day/week transitions.
+ */
public final class DesktopViewController {
private static final int SATURDAY_INDEX = 6;
@@ -56,7 +70,15 @@ public final class DesktopViewController {
private final DesktopView desktopView;
- /** Constructs the controller. */
+ /**
+ * Constructs the desktop view controller and initializes all applications,
+ * popups, event listeners, and UI bindings.
+ *
+ * @param player the player model
+ * @param gameController the main game controller
+ * @param userSelectedPath path to stock data file selected by user
+ * @param popupsController controller responsible for popup management
+ */
public DesktopViewController(
final Player player,
final GameController gameController,
@@ -83,8 +105,8 @@ public DesktopViewController(
List popups = initializeApps(gameController);
this.popupsController.addPopups(popups);
- setupPopupOverlay(popups);
- setupDesktopUI();
+ setupPopupOverlay();
+ setupDesktopUi();
setupListeners();
@@ -107,14 +129,14 @@ private List initializeApps(GameController gameController) {
AppStoreApp appStoreApp = new AppStoreApp();
gameController.addAppController(new AppStoreController(appStoreApp));
- HustlersApp hustlersApp = new HustlersApp();
+ final HustlersApp hustlersApp = new HustlersApp();
StockApp stockApp = new StockApp(player);
this.stockAppController = new StockAppController(stockApp, marketController, player);
gameController.addAppController(stockAppController);
- MailApp mailApp = new MailApp(mailController);
- NewsApp newsApp = new NewsApp();
+ final MailApp mailApp = new MailApp(mailController);
+ final NewsApp newsApp = new NewsApp();
BankApp bankApp = new BankApp();
gameController.addAppController(new BankAppController(bankApp, player));
@@ -152,7 +174,7 @@ private List initializeApps(GameController gameController) {
return popups;
}
- private void setupPopupOverlay(List popups) {
+ private void setupPopupOverlay() {
Pane overlay = desktopView.getPopupOverlay();
for (Popup p : popupsController.getPopups()) {
@@ -178,7 +200,7 @@ private void setupPopupOverlay(List popups) {
event -> weekendReportApp.getContinueButton().fire());
}
- private void setupDesktopUI() {
+ private void setupDesktopUi() {
desktopView.getNextWeekButton().setOnAction(event -> handleAdvanceWeek());
desktopView.getSettingsButton().setOnAction(event -> popupsController.show(App.SETTINGS));
@@ -224,7 +246,8 @@ private void setupListeners() {
desktopView.updateDay(startDay, startDay.equals("SUN"));
desktopView.updateWeek(timeAndWeatherController.getWeekString());
desktopView.updateWeather(timeAndWeatherController.weatherProperty().get());
- desktopView.updateTemperature(String.valueOf(timeAndWeatherController.temperatureProperty().get()));
+ desktopView.updateTemperature(String.valueOf(
+ timeAndWeatherController.temperatureProperty().get()));
desktopView.updatePlayerName(player.getName());
}
@@ -255,11 +278,11 @@ private void showInsufficientFundsWarning() {
dialogController.showInsufficientFundsWarning();
}
- private void showGameOver() {
- dialogController.showGameOver();
- }
-
- /** Sets the game over callback. */
+ /**
+ * Sets a callback that is executed when the game is over.
+ *
+ * @param callback function to run on game over
+ */
public void setOnGameOver(final Runnable callback) {
dialogController.setOnGameOver(callback);
}
@@ -268,27 +291,39 @@ private void handleLogout() {
dialogController.showGameOver(); // Or appropriate logout logic
}
- /** Creates an app button. */
+ /**
+ * Creates a UI button representing an application on the desktop.
+ *
+ * @param type the application type
+ * @return a Node representing the app button
+ */
public Node createAppButton(final App type) {
return componentFactory.createAppButton(type);
}
- /** Configures StackPane as drop target. */
+ /**
+ * Configures a StackPane to act as a drop target for draggable app icons.
+ *
+ * @param cell the UI cell to configure
+ */
public void configureCellAsDropTarget(final StackPane cell) {
componentFactory.configureCellAsDropTarget(cell);
}
- /** @return the player model. */
+ /**
+ * Returns the player model used by the desktop controller.
+ *
+ * @return the player instance
+ */
public Player getPlayer() {
return player;
}
- /** @return the time/weather controller. */
- public TimeAndWeatherController getTimeAndWeatherController() {
- return timeAndWeatherController;
- }
-
- /** @return the desktop view. */
+ /**
+ * Returns the desktop view managed by this controller.
+ *
+ * @return the desktop view
+ */
public DesktopView getDesktopView() {
return desktopView;
}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/StartViewController.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/viewcontrollers/StartViewController.java
similarity index 62%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/StartViewController.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/viewcontrollers/StartViewController.java
index fac0b0d..ee24e98 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Controller/ViewControllers/StartViewController.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/controller/viewcontrollers/StartViewController.java
@@ -1,22 +1,35 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Controller.ViewControllers;
+package edu.ntnu.idi.idatt2003.gruppe42.controller.viewcontrollers;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers.SettingsAppController;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.PopupsController;
import edu.ntnu.idi.idatt2003.gruppe42.Millions;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Difficulty;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.FilePickerApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.SettingsApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Apps.WarningApp;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Views.StartView;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.PopupsController;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.appcontrollers.SettingsAppController;
+import edu.ntnu.idi.idatt2003.gruppe42.model.App;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Difficulty;
+import edu.ntnu.idi.idatt2003.gruppe42.view.Popup;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.FilePickerApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.SettingsApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.apps.WarningApp;
+import edu.ntnu.idi.idatt2003.gruppe42.view.views.StartView;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Random;
-/** Controller for the start screen. */
+/**
+ * Controller for the start screen of the application.
+ *
+ * This controller manages:
+ *
+ * User login and username validation
+ * Game initialization with selected difficulty
+ * File selection for stock data
+ * Start screen popups and warnings
+ * Settings interactions
+ *
+ *
+ * It acts as the bridge between the StartView UI and the main application logic.
+ */
public class StartViewController {
private String username = "";
@@ -25,8 +38,8 @@ public class StartViewController {
private final Millions application;
private final PopupsController popupsController;
private Path userSelectedPath;
- private SettingsAppController settingsAppController;
- private WarningApp warningApp;
+ private final SettingsAppController settingsAppController;
+ private final WarningApp warningApp;
private static final List TATE_NAMES = List.of(
"Top G",
@@ -39,19 +52,22 @@ public class StartViewController {
"Chin Checker",
"Sparkling Water Enthusiast",
"The Talisman",
- "Epstein follower",
- "Looks Maxer",
- "Mentioned in Epstein files",
"Baby Oil Hoarder",
- "Roofie Supplier",
- "Hentai virus"
+ "Roofie Supplier"
);
+ /**
+ * Constructs the start view controller and initializes UI components,
+ * popups, and event handlers for the start screen.
+ *
+ * @param application the main application instance
+ * @param startView the start screen view
+ */
public StartViewController(final Millions application, final StartView startView) {
this.application = application;
this.startView = startView;
- List popups = new ArrayList<>();
+ final List popups = new ArrayList<>();
FilePickerApp filePickerApp = new FilePickerApp();
SettingsApp settingsApp = new SettingsApp(false);
@@ -93,11 +109,13 @@ public StartViewController(final Millions application, final StartView startView
handleStart();
});
- startView.getSettingsButton().setOnAction(actionEvent -> {
- popupsController.show(App.SETTINGS);
- });
+ startView.getSettingsButton().setOnAction(actionEvent -> popupsController.show(App.SETTINGS));
}
+ /**
+ * Starts the game by resolving the username, selecting difficulty,
+ * loading stock data, and initializing the main game.
+ */
private void handleStart() {
String resolvedName = resolveUsername(username);
String selectedMode = startView.getSelectedMode();
@@ -123,6 +141,14 @@ private void handleStart() {
application.initGame(resolvedName, difficulty, userSelectedPath, popupsController);
}
+ /**
+ * Resolves a valid username.
+ *
+ * If the input is invalid or empty, a random fallback name is selected.
+ *
+ * @param input the raw username input
+ * @return a valid username
+ */
private String resolveUsername(final String input) {
if (input == null || input.trim().isEmpty() || !isValidName(input)) {
return TATE_NAMES.get(new Random().nextInt(TATE_NAMES.size()));
@@ -130,11 +156,21 @@ private String resolveUsername(final String input) {
return input;
}
+ /**
+ * Validates whether a username contains only alphanumeric characters.
+ *
+ * @param value the username to validate
+ * @return true if the name is valid, false otherwise
+ */
private boolean isValidName(final String value) {
return value.matches("[a-zA-Z0-9]+");
}
- private void showFileWarning(){
+ /**
+ * Displays a warning when the selected stock file is invalid
+ * and prompts the user to revert to the default file.
+ */
+ private void showFileWarning() {
warningApp.configure(
"⚠",
"Invalid File",
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/App.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/App.java
similarity index 66%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/App.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/App.java
index b261d05..ecc0e47 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/App.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/App.java
@@ -1,6 +1,8 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
+package edu.ntnu.idi.idatt2003.gruppe42.model;
-/** Apps in the simulation. */
+/**
+ * Represents the applications available in the simulation.
+ */
public enum App {
APPSTORE("App Store"),
HUSTLERS("Hustlers"),
@@ -20,7 +22,11 @@ public enum App {
this.displayName = displayName;
}
- /** @return the display name. */
+ /**
+ * Returns the human-readable display name of the application.
+ *
+ * @return the display name.
+ */
public String getDisplayName() {
return displayName;
}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Day.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Day.java
new file mode 100644
index 0000000..6a3df51
--- /dev/null
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Day.java
@@ -0,0 +1,8 @@
+package edu.ntnu.idi.idatt2003.gruppe42.model;
+
+/**
+ * Represents the days of the week in the simulation.
+ */
+public enum Day {
+ MON, TUE, WED, THU, FRI, SAT, SUN
+}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Difficulty.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Difficulty.java
new file mode 100644
index 0000000..94b9540
--- /dev/null
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Difficulty.java
@@ -0,0 +1,10 @@
+package edu.ntnu.idi.idatt2003.gruppe42.model;
+
+/**
+ * Represents the difficulty levels in game.
+ */
+public enum Difficulty {
+ EASY,
+ MEDIUM,
+ HARD
+}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/EventBus.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/EventBus.java
new file mode 100644
index 0000000..13d1d48
--- /dev/null
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/EventBus.java
@@ -0,0 +1,52 @@
+package edu.ntnu.idi.idatt2003.gruppe42.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Consumer;
+
+/**
+ * Singleton event bus for communication between components.
+ *
+ *
Components can subscribe to specific event types and publish events
+ * without requiring direct references to each other.
+ */
+public class EventBus {
+ private static final EventBus INSTANCE = new EventBus();
+ private final Map, List>> listeners = new HashMap<>();
+
+ /**
+ * Returns the singleton instance of EventBus.
+ *
+ * @return the shared EventBus instance.
+ */
+ public static EventBus get() {
+ return INSTANCE;
+ }
+
+ /**
+ * Subscribes a listener to events of the given type.
+ *
+ * @param the event type.
+ * @param type the class of the event to listen for.
+ * @param listener the consumer to invoke when an event of the given type is published.
+ */
+ @SuppressWarnings("unchecked")
+ public void subscribe(Class type, Consumer listener) {
+ listeners.computeIfAbsent(type, k -> new ArrayList<>())
+ .add((Consumer) listener);
+ }
+
+ /**
+ * Publishes an event to all subscribers of its type.
+ *
+ * @param event the event to publish.
+ */
+ public void publish(Object event) {
+ List> handlers = listeners.get(event.getClass());
+ if (handlers != null) {
+ handlers.forEach(h -> h.accept(event));
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Exchange.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Exchange.java
new file mode 100644
index 0000000..a1f745f
--- /dev/null
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Exchange.java
@@ -0,0 +1,133 @@
+package edu.ntnu.idi.idatt2003.gruppe42.model;
+
+import edu.ntnu.idi.idatt2003.gruppe42.model.transaction.Purchase;
+import edu.ntnu.idi.idatt2003.gruppe42.model.transaction.Sale;
+import edu.ntnu.idi.idatt2003.gruppe42.model.transaction.Transaction;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Represents a stock exchange in the simulation.
+ *
+ * Manages a collection of stocks and supports buying, selling,
+ * searching, and advancing the simulation week.
+ */
+public class Exchange {
+ private int week;
+ private final Map stockMap;
+
+ /**
+ * Constructs an Exchange with the given list of stocks.
+ *
+ * @param stocks the stocks to list on this exchange.
+ */
+ public Exchange(final List stocks) {
+ this.week = 0;
+ this.stockMap = new HashMap<>();
+ for (Stock stock : stocks) {
+ stockMap.put(stock.getSymbol(), stock);
+ }
+ }
+
+ /**
+ * Returns the current simulation week.
+ *
+ * @return the current week.
+ */
+ public int getWeek() {
+ return week;
+ }
+
+ /**
+ * Returns whether the exchange lists a stock with the given symbol.
+ *
+ * @param symbol the stock symbol to look up.
+ * @return {@code true} if the stock exists, {@code false} otherwise.
+ */
+ public boolean hasStock(final String symbol) {
+ return stockMap.containsKey(symbol);
+ }
+
+ /**
+ * Returns the stock associated with the given symbol.
+ *
+ * @param symbol the stock symbol to look up.
+ * @return the corresponding {@link Stock}, or {@code null} if not found.
+ */
+ public Stock getStock(final String symbol) {
+ return stockMap.get(symbol);
+ }
+
+ /**
+ * Returns all stocks whose symbol or company name contains the search term.
+ *
+ * @param searchTerm the term to search for (case-insensitive).
+ * @return a list of matching stocks.
+ */
+ public List findStocks(final String searchTerm) {
+ List foundStocks = new ArrayList<>();
+ String lowerSearchTerm = searchTerm.toLowerCase();
+
+ for (Stock stock : stockMap.values()) {
+ if (stock.getCompany().toLowerCase().contains(lowerSearchTerm)
+ || stock.getSymbol().toLowerCase().contains(lowerSearchTerm)) {
+ foundStocks.add(stock);
+ }
+ }
+ return foundStocks;
+ }
+
+ /**
+ * Returns all stocks listed on this exchange.
+ *
+ * @return a list of all stocks.
+ */
+ public List getAllStocks() {
+ return new ArrayList<>(stockMap.values());
+ }
+
+ /**
+ * Creates and returns a purchase transaction for the given stock and quantity.
+ *
+ * @param symbol the symbol of the stock to buy.
+ * @param quantity the number of shares to purchase.
+ * @return a {@link Transaction} representing the purchase.
+ */
+ public Transaction buy(
+ final String symbol,
+ final BigDecimal quantity
+ ) {
+ Stock stock = getStock(symbol);
+ BigDecimal purchasePrice = stock.getSalesPrice();
+
+ Share share = new Share(stock, quantity, purchasePrice);
+ return new Purchase(share, week);
+ }
+
+ /**
+ * Creates and returns a sale transaction for the given share and quantity.
+ *
+ * @param share the share to sell.
+ * @param quantity the number of shares to sell.
+ * @return a {@link Transaction} representing the sale.
+ */
+ public Transaction sell(
+ final Share share,
+ final BigDecimal quantity
+ ) {
+ Share shareToSell = new Share(
+ share.getStock(), quantity, share.getPurchasePrice()
+ );
+ return new Sale(shareToSell, week);
+ }
+
+ /**
+ * Advances simulation by one week.
+ */
+ public void advance() {
+ week += 1;
+ }
+}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/GameFactory.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/GameFactory.java
similarity index 55%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/GameFactory.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/GameFactory.java
index 2221fa9..710f592 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/GameFactory.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/GameFactory.java
@@ -1,23 +1,26 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
+package edu.ntnu.idi.idatt2003.gruppe42.model;
import java.math.BigDecimal;
/**
- * Factory class for creating game objects.
+ * Utility factory for creating game objects.
+ *
+ * This class is not meant to be instantiated.
*/
public final class GameFactory {
+
/**
- * Private constructor to prevent instantiation.
+ * Private constructor to prevent instantiation of this utility class.
*/
private GameFactory() {
}
/**
- * Creates a new player with starting money based on difficulty.
+ * Creates a new player with starting money based on the selected difficulty.
*
- * @param username the name of the player
- * @param difficulty the game difficulty
- * @return a new Player instance
+ * @param username the name of the player.
+ * @param difficulty the selected game difficulty.
+ * @return a new {@link Player} instance with the appropriate starting funds.
*/
public static Player createPlayer(
final String username,
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/GameState.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/GameState.java
new file mode 100644
index 0000000..1bc4e69
--- /dev/null
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/GameState.java
@@ -0,0 +1,8 @@
+package edu.ntnu.idi.idatt2003.gruppe42.model;
+
+/**
+ * Represents the possible states of a simulation day.
+ */
+public enum GameState {
+ WORKDAY, RENTDAY, FREEDAY
+}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Message.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Message.java
similarity index 58%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Message.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Message.java
index 3ce0d4a..e2a08b9 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Message.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Message.java
@@ -1,10 +1,10 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
+package edu.ntnu.idi.idatt2003.gruppe42.model;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
/**
- * Represents a mail message in the game.
+ * Represents a mail message received by the player during the simulation.
*/
public class Message {
private final String author;
@@ -18,12 +18,12 @@ public class Message {
/**
* Constructs a new Message.
*
- * @param author the sender of the message
- * @param title the subject of the message
- * @param content the body of the message
- * @param week the week the message was sent
- * @param day the day the message was sent
- * @param time the time (hour) the message was sent
+ * @param author the sender of the message.
+ * @param title the subject line of the message.
+ * @param content the body text of the message.
+ * @param week the simulation week the message was sent.
+ * @param day the day of the week the message was sent.
+ * @param time the hour at which the message was sent.
*/
public Message(String author, String title, String content, int week, String day, int time) {
this.author = author;
@@ -50,31 +50,35 @@ public int getWeek() {
return week;
}
- public String getDay() {
- return day;
- }
-
- public int getTime() {
- return time;
- }
-
public boolean isSeen() {
return seen.get();
}
+ /**
+ * Sets whether the message has been read.
+ *
+ * @param seen {@code true} to mark as read, {@code false} to mark as unread.
+ */
public void setSeen(boolean seen) {
this.seen.set(seen);
}
+ /**
+ * Returns the seen property for use with JavaFX bindings.
+ *
+ * @return the seen {@link BooleanProperty}.
+ */
public BooleanProperty seenProperty() {
return seen;
}
/**
- * @return the formatted time string, e.g., "Week 1, Mon, 13:00".
+ * Returns a human-readable timestamp string for the message.
+ *
+ * @return the formatted time, e.g. {@code "Week 1, Mon, 13:00"}.
*/
public String getFormattedTime() {
- String dayStr = day.toString().toLowerCase();
+ String dayStr = day.toLowerCase();
dayStr = dayStr.substring(0, 1).toUpperCase() + dayStr.substring(1);
return String.format("Week %d, %s, %02d:00", week, dayStr, time);
}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/News.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/News.java
similarity index 98%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/News.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/News.java
index b159e5d..8eb8d75 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/News.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/News.java
@@ -1,4 +1,4 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
+package edu.ntnu.idi.idatt2003.gruppe42.model;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Player.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Player.java
similarity index 95%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Player.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Player.java
index bdb6c36..d07f6ff 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Player.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Player.java
@@ -1,7 +1,7 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
+package edu.ntnu.idi.idatt2003.gruppe42.model;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Exceptions.InsufficientFunds;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction.TransactionArchive;
+import edu.ntnu.idi.idatt2003.gruppe42.model.exceptions.InsufficientFunds;
+import edu.ntnu.idi.idatt2003.gruppe42.model.transaction.TransactionArchive;
import java.math.BigDecimal;
import javafx.beans.property.*;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Portfolio.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Portfolio.java
similarity index 61%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Portfolio.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Portfolio.java
index c7004b6..dd4700c 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Portfolio.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Portfolio.java
@@ -1,22 +1,37 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
+package edu.ntnu.idi.idatt2003.gruppe42.model;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Calculator.SaleCalculator;
+import edu.ntnu.idi.idatt2003.gruppe42.model.calculator.SaleCalculator;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
-/** Represents a player's portfolio. */
+/**
+ * Represents a player's stock portfolio.
+ *
+ *
Supports adding and removing shares, merging positions of the same stock
+ * using a weighted average purchase price, and calculating total net worth.
+ */
public class Portfolio {
private final List shares;
- /** Constructs an empty portfolio. */
+ /**
+ * Constructs an empty portfolio.
+ */
public Portfolio() {
this.shares = new ArrayList<>();
}
- /** Adds a share. */
+ /**
+ * Adds a share to the portfolio.
+ *
+ * If a share with the same stock symbol already exists, the positions are merged
+ * using a weighted average purchase price.
+ *
+ * @param share the share to add.
+ * @return {@code true} if the share was successfully added, {@code false} if the share is null.
+ */
public boolean addShare(final Share share) {
if (share == null) {
return false;
@@ -49,7 +64,16 @@ public boolean addShare(final Share share) {
return shares.add(share);
}
- /** Removes a share. */
+ /**
+ * Removes the given quantity of a share from the portfolio.
+ *
+ *
If the full quantity is sold, the position is removed entirely.
+ * If a partial quantity is sold, the position is updated with the remainder.
+ *
+ * @param newShare the share to remove, containing the stock and quantity to sell.
+ * @return {@code true} if the removal was successful, {@code false} if the share is null,
+ * not found, or the quantity exceeds the owned amount.
+ */
public boolean removeShare(final Share newShare) {
if (newShare == null) {
return false;
@@ -70,13 +94,10 @@ public boolean removeShare(final Share newShare) {
int cmp = remainingQuantity.compareTo(BigDecimal.ZERO);
if (cmp < 0) {
- // Trying to sell more than owned
return false;
} else if (cmp == 0) {
- // Selling entire position
return shares.remove(existing);
} else {
- // Partial sale, replace with new instance to ensure UI update
shares.remove(existing);
return shares.add(new Share(
existing.getStock(),
@@ -86,17 +107,25 @@ public boolean removeShare(final Share newShare) {
}
}
- /** @return list of shares. */
public List getShares() {
return shares;
}
- /** @return true if portfolio contains share. */
+ /**
+ * Returns whether the portfolio contains the given share.
+ *
+ * @param share the share to check for.
+ * @return {@code true} if the share is present, {@code false} otherwise.
+ */
public boolean contains(final Share share) {
return share != null && shares.contains(share);
}
- /** @return total net worth of shares. */
+ /**
+ * Returns the total net worth of all shares in the portfolio at current market prices.
+ *
+ * @return the total value of all held shares.
+ */
public BigDecimal getNetWorth() {
BigDecimal totalSum = BigDecimal.ZERO;
for (Share share : shares) {
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Share.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Share.java
similarity index 52%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Share.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Share.java
index 6fd48b9..d3c782b 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Share.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Share.java
@@ -1,15 +1,23 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
+package edu.ntnu.idi.idatt2003.gruppe42.model;
import java.math.BigDecimal;
import java.util.Objects;
-/** Represents owned shares. */
+/**
+ * Represents a quantity of a stock owned by the player at a specific purchase price.
+ */
public class Share {
private final Stock stock;
private BigDecimal quantity;
private final BigDecimal purchasePrice;
- /** Constructs a new share. */
+ /**
+ * Constructs a new Share.
+ *
+ * @param stock the stock this share belongs to.
+ * @param quantity the number of units owned.
+ * @param purchasePrice the price per unit at the time of purchase.
+ */
public Share(
final Stock stock,
final BigDecimal quantity,
@@ -20,27 +28,35 @@ public Share(
this.purchasePrice = purchasePrice;
}
- /** @return the stock. */
public Stock getStock() {
return stock;
}
- /** Sets quantity. */
+ /**
+ * Sets the quantity of units owned.
+ *
+ * @param quantity the new quantity.
+ */
public void setQuantity(final BigDecimal quantity) {
this.quantity = quantity;
}
- /** @return quantity. */
public BigDecimal getQuantity() {
return quantity;
}
- /** @return purchase price. */
public BigDecimal getPurchasePrice() {
return purchasePrice;
}
- /** Equals method. */
+ /**
+ * Returns whether this share is equal to another object.
+ *
+ * Two shares are equal if they have the same stock symbol, quantity, and purchase price.
+ *
+ * @param object the object to compare to.
+ * @return {@code true} if equal, {@code false} otherwise.
+ */
@Override
public boolean equals(Object object) {
if (this == object) {
@@ -51,11 +67,17 @@ public boolean equals(Object object) {
}
Share share = (Share) object;
return Objects.equals(stock.getSymbol(), share.stock.getSymbol())
- && (quantity == null ? share.quantity == null : quantity.compareTo(share.quantity) == 0)
- && (purchasePrice == null ? share.purchasePrice == null : purchasePrice.compareTo(share.purchasePrice) == 0);
+ && (quantity == null ? share.quantity == null :
+ quantity.compareTo(share.quantity) == 0)
+ && (purchasePrice == null ? share.purchasePrice == null :
+ purchasePrice.compareTo(share.purchasePrice) == 0);
}
- /** HashCode method. */
+ /**
+ * Returns a hash code based on the stock symbol, quantity, and purchase price.
+ *
+ * @return the hash code.
+ */
@Override
public int hashCode() {
return Objects.hash(stock.getSymbol(), quantity, purchasePrice);
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Status.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Status.java
similarity index 70%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Status.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Status.java
index 46e89ff..7c7d9c5 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Status.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Status.java
@@ -1,9 +1,9 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
+package edu.ntnu.idi.idatt2003.gruppe42.model;
/**
* Represents the progression level of a player.
- *
- * A player can have one of the following statuses based on their
+ *
+ *
A player can have one of the following statuses based on their
* trading activity and net worth growth
*
*
*/
public enum Status {
- /** Initial level for all players. */
NOVICE,
- /** Intermediate level. */
INVESTOR,
- /** High level. */
SPECULATOR
}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Stock.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Stock.java
similarity index 93%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Stock.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Stock.java
index 9699d9a..9751c9a 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Stock.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/Stock.java
@@ -1,7 +1,7 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
+package edu.ntnu.idi.idatt2003.gruppe42.model;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.StockController;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Views.Components.StockGraph;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.StockController;
+import edu.ntnu.idi.idatt2003.gruppe42.view.views.components.StockGraph;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/StockEvent.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/StockEvent.java
new file mode 100644
index 0000000..e5b500c
--- /dev/null
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/StockEvent.java
@@ -0,0 +1,9 @@
+package edu.ntnu.idi.idatt2003.gruppe42.model;
+
+/**
+ * Represents a market event affecting a specific company's stock trend.
+ *
+ * @param company the name of the company affected by the event.
+ * @param trend the trend direction; positive for good news, negative for bad news.
+ */
+public record StockEvent(String company, int trend) {}
\ No newline at end of file
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/StockFileHandler.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/StockFileHandler.java
similarity index 72%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/StockFileHandler.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/StockFileHandler.java
index f616718..17859fd 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/StockFileHandler.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/StockFileHandler.java
@@ -1,6 +1,6 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
+package edu.ntnu.idi.idatt2003.gruppe42.model;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Exceptions.StockFileParseException;
+import edu.ntnu.idi.idatt2003.gruppe42.model.exceptions.StockFileParseException;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
@@ -13,17 +13,34 @@
import java.util.List;
import java.util.regex.Pattern;
-/** Utility for handling stock file data. */
+/**
+ * Utility class for reading and parsing stock data from CSV files.
+ *
+ * Each line in the file must contain exactly three comma-separated fields:
+ * a ticker symbol, a company name, and a price with exactly two decimal places.
+ * Blank lines and lines starting with {@code #} are ignored.
+ */
public final class StockFileHandler {
private static final Pattern SYMBOL_PATTERN = Pattern.compile("^[A-Z.]{1,5}$");
private static final Pattern PRICE_PATTERN = Pattern.compile("^\\d+\\.\\d{2}$");
private static final int EXPECTED_FIELDS = 3;
- /** Private constructor. */
- private StockFileHandler() {
- }
-
- /** Parses stock data from file. */
+ /**
+ * Private constructor to prevent instantiation of this utility class.
+ */
+ private StockFileHandler() {}
+
+ /**
+ * Reads and parses a list of stocks from a CSV file at the given path.
+ *
+ *
Each valid line must follow the format: {@code SYMBOL,Company Name,price}
+ * (e.g. {@code AAPL,Apple Inc,191.27}).
+ *
+ * @param path the path to the stock data file.
+ * @return a list of parsed {@link Stock} objects.
+ * @throws IOException if the file does not exist or cannot be read.
+ * @throws StockFileParseException if any line contains invalid or malformed data.
+ */
public static List readFromFile(final Path path)
throws IOException, StockFileParseException {
@@ -45,7 +62,6 @@ public static List readFromFile(final Path path)
lineNumber++;
String trimmed = line.trim();
- // Skip blank lines and comments
if (trimmed.isEmpty() || trimmed.startsWith("#")) {
continue;
}
@@ -65,7 +81,8 @@ public static List readFromFile(final Path path)
}
if (!SYMBOL_PATTERN.matcher(symbol).matches()) {
throw new StockFileParseException(lineNumber, trimmed,
- String.format("Ticker symbol \"%s\" is invalid — must be exactly 3 uppercase letters (A-Z)", symbol));
+ String.format("Ticker symbol \"%s\" is invalid — "
+ + "must be exactly 3 uppercase letters (A-Z)", symbol));
}
String company = parts[1].trim();
@@ -77,7 +94,8 @@ public static List readFromFile(final Path path)
String rawPrice = parts[2].trim();
if (!PRICE_PATTERN.matcher(rawPrice).matches()) {
throw new StockFileParseException(lineNumber, trimmed,
- String.format("Price \"%s\" is invalid — must be a positive number with exactly 2 decimal places using '.' (e.g. 191.27)", rawPrice));
+ String.format("Price \"%s\" is invalid — must be a positive number "
+ + "with exactly 2 decimal places using '.' (e.g. 191.27)", rawPrice));
}
BigDecimal price;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Calculator/PurchaseCalculator.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/PurchaseCalculator.java
similarity index 53%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Calculator/PurchaseCalculator.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/PurchaseCalculator.java
index 29a0495..b1b8cd3 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Calculator/PurchaseCalculator.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/PurchaseCalculator.java
@@ -1,54 +1,62 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model.Calculator;
+package edu.ntnu.idi.idatt2003.gruppe42.model.calculator;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Share;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Share;
import java.math.BigDecimal;
/**
- * Calculator for stock purchase transactions.
+ * Calculates the cost of a stock purchase transaction, including commission.
*/
public final class PurchaseCalculator implements TransactionCalculator {
private final BigDecimal purchasePrice;
private final BigDecimal quantity;
/**
- * Constructs a new PurchaseCalculator.
+ * Constructs a new PurchaseCalculator for the given share position.
*
- * @param share the share position being bought
+ * @param share the share being purchased.
*/
public PurchaseCalculator(final Share share) {
this.purchasePrice = share.getPurchasePrice();
this.quantity = share.getQuantity();
}
- @Override
/**
- * Calculategross method.
+ * Returns the gross cost of the purchase before commission.
+ *
+ * @return the purchase price multiplied by the quantity.
*/
+ @Override
public BigDecimal calculateGross() {
return purchasePrice.multiply(quantity);
}
- @Override
/**
- * Calculatecommission method.
+ * Returns the commission charged on the purchase.
+ *
+ * @return 1% of the gross cost.
*/
+ @Override
public BigDecimal calculateCommission() {
final BigDecimal commissionRate = new BigDecimal("0.01");
return calculateGross().multiply(commissionRate);
}
- @Override
/**
- * Calculatetax method.
+ * Returns the tax applied to the purchase.
+ *
+ * @return {@link BigDecimal#ZERO}, as purchases are not taxed.
*/
+ @Override
public BigDecimal calculateTax() {
return BigDecimal.ZERO;
}
- @Override
/**
- * Calculatetotal method.
+ * Returns the total cost of the purchase including commission and tax.
+ *
+ * @return the sum of gross cost, commission, and tax.
*/
+ @Override
public BigDecimal calculateTotal() {
return calculateGross().add(calculateCommission()).add(calculateTax());
}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Calculator/SaleCalculator.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/SaleCalculator.java
similarity index 57%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Calculator/SaleCalculator.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/SaleCalculator.java
index 4bdebbf..332b1f9 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Calculator/SaleCalculator.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/SaleCalculator.java
@@ -1,10 +1,10 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model.Calculator;
+package edu.ntnu.idi.idatt2003.gruppe42.model.calculator;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Share;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Share;
import java.math.BigDecimal;
/**
- * Calculator for stock sale transactions.
+ * Calculates the proceeds of a stock sale transaction, including commission and capital gains tax.
*/
public final class SaleCalculator implements TransactionCalculator {
private final BigDecimal purchasePrice;
@@ -12,9 +12,9 @@ public final class SaleCalculator implements TransactionCalculator {
private final BigDecimal quantity;
/**
- * Constructs a new SaleCalculator.
+ * Constructs a new SaleCalculator for the given share position.
*
- * @param share the share position being sold
+ * @param share the share being sold.
*/
public SaleCalculator(Share share) {
this.purchasePrice = share.getPurchasePrice();
@@ -22,27 +22,34 @@ public SaleCalculator(Share share) {
this.quantity = share.getQuantity();
}
- @Override
/**
- * Calculategross method.
+ * Returns the gross proceeds of the sale before deductions.
+ *
+ * @return the current sales price multiplied by the quantity.
*/
+ @Override
public BigDecimal calculateGross() {
return salesPrice.multiply(quantity);
}
- @Override
/**
- * Calculatecommission method.
+ * Returns the commission charged on the sale.
+ *
+ * @return 1% of the gross proceeds.
*/
+ @Override
public BigDecimal calculateCommission() {
final BigDecimal commissionRate = new BigDecimal("0.01");
return calculateGross().multiply(commissionRate);
}
- @Override
/**
- * Calculatetax method.
+ * Returns the capital gains tax applied to the sale.
+ *
+ * @return 22% of the profit per share multiplied by the quantity,
+ * based on the difference between the sales price and purchase price.
*/
+ @Override
public BigDecimal calculateTax() {
final BigDecimal taxRate = new BigDecimal("0.22");
BigDecimal differencePrice = salesPrice.subtract(purchasePrice);
@@ -50,10 +57,12 @@ public BigDecimal calculateTax() {
return difference.multiply(taxRate);
}
- @Override
/**
- * Calculatetotal method.
+ * Returns the net proceeds of the sale after commission and tax.
+ *
+ * @return the gross proceeds minus commission and tax.
*/
+ @Override
public BigDecimal calculateTotal() {
return calculateGross().subtract(calculateCommission())
.subtract(calculateTax());
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Calculator/TransactionCalculator.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/TransactionCalculator.java
similarity index 92%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Calculator/TransactionCalculator.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/TransactionCalculator.java
index cf606fe..21b6c7f 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Calculator/TransactionCalculator.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/TransactionCalculator.java
@@ -1,4 +1,4 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model.Calculator;
+package edu.ntnu.idi.idatt2003.gruppe42.model.calculator;
import java.math.BigDecimal;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Exceptions/InsufficientFunds.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/exceptions/InsufficientFunds.java
similarity index 85%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Exceptions/InsufficientFunds.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/exceptions/InsufficientFunds.java
index 55f990f..c9b2c59 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Exceptions/InsufficientFunds.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/exceptions/InsufficientFunds.java
@@ -1,4 +1,4 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model.Exceptions;
+package edu.ntnu.idi.idatt2003.gruppe42.model.exceptions;
/**
* Exception thrown when a player has insufficient funds for a transaction.
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Exceptions/StockFileParseException.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/exceptions/StockFileParseException.java
similarity index 89%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Exceptions/StockFileParseException.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/exceptions/StockFileParseException.java
index 8fd4e91..07f4afa 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Exceptions/StockFileParseException.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/exceptions/StockFileParseException.java
@@ -1,4 +1,4 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model.Exceptions;
+package edu.ntnu.idi.idatt2003.gruppe42.model.exceptions;
public class StockFileParseException extends Exception {
private final int lineNumber;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Purchase.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/Purchase.java
similarity index 68%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Purchase.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/Purchase.java
index 4c3f1a3..30dfc20 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Purchase.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/Purchase.java
@@ -1,8 +1,8 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction;
+package edu.ntnu.idi.idatt2003.gruppe42.model.transaction;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Calculator.PurchaseCalculator;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Player;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Share;
+import edu.ntnu.idi.idatt2003.gruppe42.model.calculator.PurchaseCalculator;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Player;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Share;
/** Represents a stock purchase. */
public final class Purchase extends Transaction {
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Sale.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/Sale.java
similarity index 65%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Sale.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/Sale.java
index 55c0c4c..c509a39 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Sale.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/Sale.java
@@ -1,8 +1,8 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction;
+package edu.ntnu.idi.idatt2003.gruppe42.model.transaction;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Calculator.SaleCalculator;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Player;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Share;
+import edu.ntnu.idi.idatt2003.gruppe42.model.calculator.SaleCalculator;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Player;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Share;
/** Represents a stock sale. */
public final class Sale extends Transaction {
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Transaction.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/Transaction.java
similarity index 82%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Transaction.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/Transaction.java
index f5024e4..196825b 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/Transaction.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/Transaction.java
@@ -1,8 +1,8 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction;
+package edu.ntnu.idi.idatt2003.gruppe42.model.transaction;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Calculator.TransactionCalculator;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Player;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Share;
+import edu.ntnu.idi.idatt2003.gruppe42.model.calculator.TransactionCalculator;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Player;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Share;
/** Base class for transactions. */
public abstract class Transaction {
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/TransactionArchive.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/TransactionArchive.java
similarity index 97%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/TransactionArchive.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/TransactionArchive.java
index b594724..fd9b15d 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/TransactionArchive.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/TransactionArchive.java
@@ -1,4 +1,4 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction;
+package edu.ntnu.idi.idatt2003.gruppe42.model.transaction;
import java.math.BigDecimal;
import java.util.ArrayList;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Popup.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/Popup.java
similarity index 82%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Popup.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/Popup.java
index a2c6df4..e0d27dd 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Popup.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/Popup.java
@@ -1,6 +1,6 @@
-package edu.ntnu.idi.idatt2003.gruppe42.View;
+package edu.ntnu.idi.idatt2003.gruppe42.view;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
+import edu.ntnu.idi.idatt2003.gruppe42.model.App;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@@ -20,13 +20,25 @@
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
-/** Base class for draggable popups. */
+/**
+ * Base class for draggable popup windows in the application.
+ *
+ * This class provides common functionality for all popups, including:
+ *
+ * Draggable window behavior
+ * Styled header with close button
+ * Scrollable content area
+ * Dynamic stylesheet loading per application type
+ * Centering and visibility control
+ *
+ *
+ * Each popup is associated with an {@link App} type that determines
+ * its styling and behavior.
+ */
public abstract class Popup {
private static final double ARC = 16;
- private final int width;
- private final int height;
private final App type;
private final Pane wrapper;
@@ -37,9 +49,16 @@ public abstract class Popup {
protected final VBox content;
protected final ScrollPane scrollPane;
+ /**
+ * Constructs a popup window with specified size and position.
+ *
+ * @param width the width of the popup
+ * @param height the height of the popup
+ * @param x the initial X position
+ * @param y the initial Y position
+ * @param type the application type defining popup styling
+ */
protected Popup(int width, int height, int x, int y, App type) {
- this.width = width;
- this.height = height;
this.type = type;
content = new VBox();
@@ -166,7 +185,11 @@ private String resource(final String path) {
return Objects.requireNonNull(getClass().getResource(path)).toExternalForm();
}
- /** Centers the popup in its parent. */
+ /**
+ * Centers the popup inside its parent container.
+ *
+ *
The popup will remain centered even when the parent resizes.
+ */
public void centerInParent() {
Runnable bind = () -> {
if (wrapper.getParent() instanceof Pane pane) {
@@ -181,33 +204,38 @@ public void centerInParent() {
wrapper.parentProperty().addListener((obs, oldParent, newParent) -> bind.run());
}
- /** Shows the popup. */
+ /**
+ * Makes the popup visible and brings it to the front.
+ */
public void show() {
wrapper.setVisible(true);
wrapper.toFront();
}
- /** Hides the popup. */
+ /**
+ * Hides the popup from view.
+ */
public void hide() {
wrapper.setVisible(false);
}
- /** @return the type. */
+ /**
+ * Returns the application type associated with this popup.
+ *
+ * @return the popup's {@link App} type
+ */
public App getType() {
return type;
}
- /** @return the root wrapper. */
public Pane getRoot() {
return wrapper;
}
- /** @return the header. */
public HBox getHeader() {
return header;
}
- /** @return the close button. */
public Button getCloseButton() {
return closeButton;
}
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/AppStoreApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/AppStoreApp.java
similarity index 63%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/AppStoreApp.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/AppStoreApp.java
index 4763bc4..fed24d1 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/AppStoreApp.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/AppStoreApp.java
@@ -1,7 +1,7 @@
-package edu.ntnu.idi.idatt2003.gruppe42.View.Apps;
+package edu.ntnu.idi.idatt2003.gruppe42.view.apps;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
+import edu.ntnu.idi.idatt2003.gruppe42.model.App;
+import edu.ntnu.idi.idatt2003.gruppe42.view.Popup;
/**
* A popup for the app store app.
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/BankApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/BankApp.java
similarity index 98%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/BankApp.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/BankApp.java
index a233619..9d34d70 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/BankApp.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/BankApp.java
@@ -1,8 +1,8 @@
-package edu.ntnu.idi.idatt2003.gruppe42.View.Apps;
+package edu.ntnu.idi.idatt2003.gruppe42.view.apps;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Share;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
+import edu.ntnu.idi.idatt2003.gruppe42.model.App;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Share;
+import edu.ntnu.idi.idatt2003.gruppe42.view.Popup;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.function.Consumer;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/FilePickerApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/FilePickerApp.java
similarity index 98%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/FilePickerApp.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/FilePickerApp.java
index b165959..7ba8668 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/FilePickerApp.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/FilePickerApp.java
@@ -1,7 +1,7 @@
-package edu.ntnu.idi.idatt2003.gruppe42.View.Apps;
+package edu.ntnu.idi.idatt2003.gruppe42.view.apps;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
+import edu.ntnu.idi.idatt2003.gruppe42.model.App;
+import edu.ntnu.idi.idatt2003.gruppe42.view.Popup;
import java.io.File;
import java.nio.file.Path;
import java.util.Arrays;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/GameOverApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/GameOverApp.java
similarity index 90%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/GameOverApp.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/GameOverApp.java
index c0cb8f8..aea7d44 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/GameOverApp.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/GameOverApp.java
@@ -1,7 +1,7 @@
-package edu.ntnu.idi.idatt2003.gruppe42.View.Apps;
+package edu.ntnu.idi.idatt2003.gruppe42.view.apps;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
+import edu.ntnu.idi.idatt2003.gruppe42.model.App;
+import edu.ntnu.idi.idatt2003.gruppe42.view.Popup;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/HustlersApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/HustlersApp.java
similarity index 99%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/HustlersApp.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/HustlersApp.java
index d4bba00..a7bdc69 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/HustlersApp.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/HustlersApp.java
@@ -1,7 +1,7 @@
-package edu.ntnu.idi.idatt2003.gruppe42.View.Apps;
+package edu.ntnu.idi.idatt2003.gruppe42.view.apps;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
+import edu.ntnu.idi.idatt2003.gruppe42.model.App;
+import edu.ntnu.idi.idatt2003.gruppe42.view.Popup;
import java.util.LinkedHashMap;
import java.util.Map;
import javafx.geometry.Insets;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/MailApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/MailApp.java
similarity index 91%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/MailApp.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/MailApp.java
index 110d856..d420fae 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/MailApp.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/MailApp.java
@@ -1,9 +1,9 @@
-package edu.ntnu.idi.idatt2003.gruppe42.View.Apps;
+package edu.ntnu.idi.idatt2003.gruppe42.view.apps;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.AppControllers.MailController;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Message;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.appcontrollers.MailController;
+import edu.ntnu.idi.idatt2003.gruppe42.model.App;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Message;
+import edu.ntnu.idi.idatt2003.gruppe42.view.Popup;
import javafx.collections.ListChangeListener;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
@@ -98,7 +98,7 @@ private VBox createMailItem(Message message) {
item.getChildren().addAll(top, subLabel, contentLabel);
- if (!message.isSeen()) {
+ if (message.isSeen()) {
HBox bottom = new HBox();
bottom.setAlignment(Pos.CENTER_RIGHT);
Button seenButton = new Button("Mark as Read");
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/NewsApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/NewsApp.java
similarity index 57%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/NewsApp.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/NewsApp.java
index 170b043..d4f3019 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/NewsApp.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/NewsApp.java
@@ -1,7 +1,7 @@
-package edu.ntnu.idi.idatt2003.gruppe42.View.Apps;
+package edu.ntnu.idi.idatt2003.gruppe42.view.apps;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
+import edu.ntnu.idi.idatt2003.gruppe42.model.App;
+import edu.ntnu.idi.idatt2003.gruppe42.view.Popup;
/** News app popup. */
public class NewsApp extends Popup {
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/SettingsApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/SettingsApp.java
similarity index 98%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/SettingsApp.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/SettingsApp.java
index ea4b10f..22ef4e4 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/SettingsApp.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/SettingsApp.java
@@ -1,7 +1,7 @@
-package edu.ntnu.idi.idatt2003.gruppe42.View.Apps;
+package edu.ntnu.idi.idatt2003.gruppe42.view.apps;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
+import edu.ntnu.idi.idatt2003.gruppe42.model.App;
+import edu.ntnu.idi.idatt2003.gruppe42.view.Popup;
import java.nio.file.Path;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/StockApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/StockApp.java
similarity index 93%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/StockApp.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/StockApp.java
index b81da2a..c9d30d8 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/StockApp.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/StockApp.java
@@ -1,11 +1,11 @@
-package edu.ntnu.idi.idatt2003.gruppe42.View.Apps;
-
-import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Player;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Stock;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Views.Components.Receipt;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Views.Components.StockGraph;
+package edu.ntnu.idi.idatt2003.gruppe42.view.apps;
+
+import edu.ntnu.idi.idatt2003.gruppe42.model.App;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Player;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Stock;
+import edu.ntnu.idi.idatt2003.gruppe42.view.Popup;
+import edu.ntnu.idi.idatt2003.gruppe42.view.views.components.Receipt;
+import edu.ntnu.idi.idatt2003.gruppe42.view.views.components.StockGraph;
import java.math.BigDecimal;
import javafx.application.Platform;
import javafx.geometry.Insets;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/WarningApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/WarningApp.java
similarity index 95%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/WarningApp.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/WarningApp.java
index e1dc39d..34b1fb3 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/WarningApp.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/WarningApp.java
@@ -1,7 +1,7 @@
-package edu.ntnu.idi.idatt2003.gruppe42.View.Apps;
+package edu.ntnu.idi.idatt2003.gruppe42.view.apps;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
+import edu.ntnu.idi.idatt2003.gruppe42.model.App;
+import edu.ntnu.idi.idatt2003.gruppe42.view.Popup;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/WeekendReportApp.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/WeekendReportApp.java
similarity index 96%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/WeekendReportApp.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/WeekendReportApp.java
index 6014ee1..8baca67 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Apps/WeekendReportApp.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/apps/WeekendReportApp.java
@@ -1,9 +1,9 @@
-package edu.ntnu.idi.idatt2003.gruppe42.View.Apps;
+package edu.ntnu.idi.idatt2003.gruppe42.view.apps;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction.Transaction;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Popup;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Views.Components.Receipt;
+import edu.ntnu.idi.idatt2003.gruppe42.model.App;
+import edu.ntnu.idi.idatt2003.gruppe42.model.transaction.Transaction;
+import edu.ntnu.idi.idatt2003.gruppe42.view.Popup;
+import edu.ntnu.idi.idatt2003.gruppe42.view.views.components.Receipt;
import java.math.BigDecimal;
import java.util.List;
import javafx.geometry.Insets;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/DesktopView.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/views/DesktopView.java
similarity index 97%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/DesktopView.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/views/DesktopView.java
index 1642eac..19f352d 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/DesktopView.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/views/DesktopView.java
@@ -1,8 +1,8 @@
-package edu.ntnu.idi.idatt2003.gruppe42.View.Views;
+package edu.ntnu.idi.idatt2003.gruppe42.view.views;
-import edu.ntnu.idi.idatt2003.gruppe42.Controller.ViewControllers.DesktopViewController;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.App;
-import edu.ntnu.idi.idatt2003.gruppe42.View.Views.Components.DesktopBottomBar;
+import edu.ntnu.idi.idatt2003.gruppe42.controller.viewcontrollers.DesktopViewController;
+import edu.ntnu.idi.idatt2003.gruppe42.model.App;
+import edu.ntnu.idi.idatt2003.gruppe42.view.views.components.DesktopBottomBar;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/StartView.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/views/StartView.java
similarity index 98%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/StartView.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/views/StartView.java
index b51e31e..3f04b6f 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/StartView.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/views/StartView.java
@@ -1,4 +1,4 @@
-package edu.ntnu.idi.idatt2003.gruppe42.View.Views;
+package edu.ntnu.idi.idatt2003.gruppe42.view.views;
import java.util.Objects;
import javafx.geometry.Pos;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/Components/DesktopBottomBar.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/views/components/DesktopBottomBar.java
similarity index 97%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/Components/DesktopBottomBar.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/views/components/DesktopBottomBar.java
index f709f28..dbb7310 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/Components/DesktopBottomBar.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/views/components/DesktopBottomBar.java
@@ -1,6 +1,6 @@
-package edu.ntnu.idi.idatt2003.gruppe42.View.Views.Components;
+package edu.ntnu.idi.idatt2003.gruppe42.view.views.components;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Player;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Player;
import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/Components/Receipt.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/views/components/Receipt.java
similarity index 94%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/Components/Receipt.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/views/components/Receipt.java
index 6fe0029..a35fbf0 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/Components/Receipt.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/views/components/Receipt.java
@@ -1,10 +1,10 @@
-package edu.ntnu.idi.idatt2003.gruppe42.View.Views.Components;
+package edu.ntnu.idi.idatt2003.gruppe42.view.views.components;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Player;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Share;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Stock;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction.Purchase;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction.Transaction;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Player;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Share;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Stock;
+import edu.ntnu.idi.idatt2003.gruppe42.model.transaction.Purchase;
+import edu.ntnu.idi.idatt2003.gruppe42.model.transaction.Transaction;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Optional;
diff --git a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/Components/StockGraph.java b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/views/components/StockGraph.java
similarity index 95%
rename from src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/Components/StockGraph.java
rename to src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/views/components/StockGraph.java
index 081e58d..23d85f7 100644
--- a/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/View/Views/Components/StockGraph.java
+++ b/src/main/java/edu/ntnu/idi/idatt2003/gruppe42/view/views/components/StockGraph.java
@@ -1,6 +1,6 @@
-package edu.ntnu.idi.idatt2003.gruppe42.View.Views.Components;
+package edu.ntnu.idi.idatt2003.gruppe42.view.views.components;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Stock;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Stock;
import javafx.application.Platform;
import javafx.scene.chart.AreaChart;
import javafx.scene.chart.NumberAxis;
diff --git a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/CriticalFeaturesTest.java b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/CriticalFeaturesTest.java
index e258808..2b98fba 100644
--- a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/CriticalFeaturesTest.java
+++ b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/CriticalFeaturesTest.java
@@ -3,10 +3,10 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Player;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Portfolio;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Share;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Stock;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Player;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Portfolio;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Share;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Stock;
import java.math.BigDecimal;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
diff --git a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/ExchangeTest.java b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/ExchangeTest.java
similarity index 97%
rename from src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/ExchangeTest.java
rename to src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/ExchangeTest.java
index ec9ee0d..2bd565c 100644
--- a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/ExchangeTest.java
+++ b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/ExchangeTest.java
@@ -1,4 +1,4 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
+package edu.ntnu.idi.idatt2003.gruppe42.model;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
diff --git a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/PlayerTest.java b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/PlayerTest.java
similarity index 95%
rename from src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/PlayerTest.java
rename to src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/PlayerTest.java
index 6e6c405..48cec18 100644
--- a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/PlayerTest.java
+++ b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/PlayerTest.java
@@ -1,11 +1,11 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
+package edu.ntnu.idi.idatt2003.gruppe42.model;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Exceptions.InsufficientFunds;
+import edu.ntnu.idi.idatt2003.gruppe42.model.exceptions.InsufficientFunds;
import java.math.BigDecimal;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
diff --git a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/PortfolioTest.java b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/PortfolioTest.java
similarity index 96%
rename from src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/PortfolioTest.java
rename to src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/PortfolioTest.java
index dc47d57..6680e62 100644
--- a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/PortfolioTest.java
+++ b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/PortfolioTest.java
@@ -1,4 +1,4 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
+package edu.ntnu.idi.idatt2003.gruppe42.model;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
diff --git a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/ShareTest.java b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/ShareTest.java
similarity index 92%
rename from src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/ShareTest.java
rename to src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/ShareTest.java
index 68ecfec..44715dc 100644
--- a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/ShareTest.java
+++ b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/ShareTest.java
@@ -1,4 +1,4 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
+package edu.ntnu.idi.idatt2003.gruppe42.model;
import static org.junit.jupiter.api.Assertions.assertEquals;
diff --git a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/StockFileHandlerTest.java b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/StockFileHandlerTest.java
similarity index 93%
rename from src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/StockFileHandlerTest.java
rename to src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/StockFileHandlerTest.java
index 26d3711..6e3af16 100644
--- a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/StockFileHandlerTest.java
+++ b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/StockFileHandlerTest.java
@@ -1,10 +1,9 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
+package edu.ntnu.idi.idatt2003.gruppe42.model;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
-import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
diff --git a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/StockTest.java b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/StockTest.java
similarity index 93%
rename from src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/StockTest.java
rename to src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/StockTest.java
index 396be27..7309f59 100644
--- a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/StockTest.java
+++ b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/StockTest.java
@@ -1,4 +1,4 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model;
+package edu.ntnu.idi.idatt2003.gruppe42.model;
import static org.junit.jupiter.api.Assertions.assertEquals;
diff --git a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Calculator/PurchaseCalculatorTest.java b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/PurchaseCalculatorTest.java
similarity index 94%
rename from src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Calculator/PurchaseCalculatorTest.java
rename to src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/PurchaseCalculatorTest.java
index f102c7a..e74eed3 100644
--- a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Calculator/PurchaseCalculatorTest.java
+++ b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/PurchaseCalculatorTest.java
@@ -1,10 +1,10 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model.Calculator;
+package edu.ntnu.idi.idatt2003.gruppe42.model.calculator;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Share;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Stock;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Share;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Stock;
import java.math.BigDecimal;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
diff --git a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Calculator/SaleCalculatorTest.java b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/SaleCalculatorTest.java
similarity index 94%
rename from src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Calculator/SaleCalculatorTest.java
rename to src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/SaleCalculatorTest.java
index 0ba8dea..90aad67 100644
--- a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Calculator/SaleCalculatorTest.java
+++ b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/calculator/SaleCalculatorTest.java
@@ -1,10 +1,10 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model.Calculator;
+package edu.ntnu.idi.idatt2003.gruppe42.model.calculator;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Share;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Stock;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Share;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Stock;
import java.math.BigDecimal;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
diff --git a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/TransactionArchiveTest.java b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/TransactionArchiveTest.java
similarity index 91%
rename from src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/TransactionArchiveTest.java
rename to src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/TransactionArchiveTest.java
index 557bbec..a02dea9 100644
--- a/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/Model/Transaction/TransactionArchiveTest.java
+++ b/src/test/java/edu/ntnu/idi/idatt2003/gruppe42/model/transaction/TransactionArchiveTest.java
@@ -1,11 +1,11 @@
-package edu.ntnu.idi.idatt2003.gruppe42.Model.Transaction;
+package edu.ntnu.idi.idatt2003.gruppe42.model.transaction;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Share;
-import edu.ntnu.idi.idatt2003.gruppe42.Model.Stock;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Share;
+import edu.ntnu.idi.idatt2003.gruppe42.model.Stock;
import java.math.BigDecimal;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;